Part Number Hot Search : 
2SK2062 14515 TDA1015 STW9N150 F1010EZ APU4006 MZ4624 FAN8729
Product Description
Full Text Search
 

To Download USAA13CA703000-XX Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
 Application Note
Guide to Porting from CC78K4 to CA850
Target Devices V850 FamilyTM Target Tools CA850 Ver. 2.40 CC78K4 Ver. 2.20 RA78K4 Ver. 1.30
Document No. U15653EJ1V0AN00 (1st edition) Date Published September 2001 N CP(K)
(c) 1999 2001 Printed in Japan
[MEMO]
2
Application Note U15653EJ1V0AN
V800 Series, V850 Family, V851, V852, V853, V854, V850/SA1, V850/SB1, V850/SB2, V850/SV1, V850/SF1, V850E/MS1, V850E/MS2, V850E/MA1, V850E/MA2, V850E/IA1, and V850E/IA2 are trademarks of NEC Corporation. Windows is either a registered trademark or a trademark of Microsoft Corporation in the United States and/or other countries.
Application Note U15653EJ1V0AN
3
* The information in this document is current as of July, 2001. The information is subject to change without notice. For actual design-in, refer to the latest publications of NEC's data sheets or data books, etc., for the most up-to-date specifications of NEC semiconductor products. Not all products and/or types are available in every country. Please check with an NEC sales representative for availability and additional information. * No part of this document may be copied or reproduced in any form or by any means without prior written consent of NEC. NEC assumes no responsibility for any errors that may appear in this document. * NEC does not assume any liability for infringement of patents, copyrights or other intellectual property rights of third parties by or arising from the use of NEC semiconductor products listed in this document or any other liability arising from the use of such products. No license, express, implied or otherwise, is granted under any patents, copyrights or other intellectual property rights of NEC or others. * Descriptions of circuits, software and other related information in this document are provided for illustrative purposes in semiconductor product operation and application examples. The incorporation of these circuits, software and information in the design of customer's equipment shall be done under the full responsibility of customer. NEC assumes no responsibility for any losses incurred by customers or third parties arising from the use of these circuits, software and information. * While NEC endeavours to enhance the quality, reliability and safety of NEC semiconductor products, customers agree and acknowledge that the possibility of defects thereof cannot be eliminated entirely. To minimize risks of damage to property or injury (including death) to persons arising from defects in NEC semiconductor products, customers must incorporate sufficient safety measures in their design, such as redundancy, fire-containment, and anti-failure features. * NEC semiconductor products are classified into the following three quality grades: "Standard", "Special" and "Specific". The "Specific" quality grade applies only to semiconductor products developed based on a customer-designated "quality assurance program" for a specific application. The recommended applications of a semiconductor product depend on its quality grade, as indicated below. Customers must check the quality grade of each semiconductor product before using it in a particular application. "Standard": Computers, office equipment, communications equipment, test and measurement equipment, audio and visual equipment, home electronic appliances, machine tools, personal electronic equipment and industrial robots "Special": Transportation equipment (automobiles, trains, ships, etc.), traffic control systems, anti-disaster systems, anti-crime systems, safety equipment and medical equipment (not specifically designed for life support) "Specific": Aircraft, aerospace equipment, submersible repeaters, nuclear reactor control systems, life support systems and medical equipment for life support, etc. The quality grade of NEC semiconductor products is "Standard" unless otherwise expressly specified in NEC's data sheets or data books, etc. If customers wish to use NEC semiconductor products in applications not intended by NEC, they must contact an NEC sales representative in advance to determine NEC's willingness to support a given application. (Note) (1) "NEC" as used in this statement means NEC Corporation and also includes its majority-owned subsidiaries. (2) "NEC semiconductor products" means any semiconductor product developed or manufactured by or for NEC (as defined above).
M8E 00.4
4
Application Note U15653EJ1V0AN
Regional Information
Some information contained in this document may vary from country to country. Before using any NEC product in your application, pIease contact the NEC office in your country to obtain a list of authorized representatives and distributors. They will verify:
* * * * *
Device availability Ordering information Product release schedule Availability of related technical literature Development environment specifications (for example, specifications for third-party tools and components, host computers, power plugs, AC supply voltages, and so forth) Network requirements
*
In addition, trademarks, registered trademarks, export restrictions, and other legal issues may also vary from country to country.
NEC Electronics Inc. (U.S.)
Santa Clara, California Tel: 408-588-6000 800-366-9782 Fax: 408-588-6130 800-729-9288
NEC Electronics (Germany) GmbH
Benelux Office Eindhoven, The Netherlands Tel: 040-2445845 Fax: 040-2444580
NEC Electronics Hong Kong Ltd.
Hong Kong Tel: 2886-9318 Fax: 2886-9022/9044
NEC Electronics Hong Kong Ltd. NEC Electronics (France) S.A.
Velizy-Villacoublay, France Tel: 01-3067-5800 Fax: 01-3067-5899 Seoul Branch Seoul, Korea Tel: 02-528-0303 Fax: 02-528-4411
NEC Electronics (Germany) GmbH
Duesseldorf, Germany Tel: 0211-65 03 02 Fax: 0211-65 03 490
NEC Electronics (France) S.A. NEC Electronics (UK) Ltd.
Milton Keynes, UK Tel: 01908-691-133 Fax: 01908-670-290 Madrid Office Madrid, Spain Tel: 091-504-2787 Fax: 091-504-2860
NEC Electronics Singapore Pte. Ltd.
Novena Square, Singapore Tel: 253-8311 Fax: 250-3583
NEC Electronics Taiwan Ltd. NEC Electronics Italiana s.r.l.
Milano, Italy Tel: 02-66 75 41 Fax: 02-66 75 42 99
NEC Electronics (Germany) GmbH
Scandinavia Office Taeby, Sweden Tel: 08-63 80 820 Fax: 08-63 80 388
Taipei, Taiwan Tel: 02-2719-2377 Fax: 02-2719-5951
NEC do Brasil S.A.
Electron Devices Division Guarulhos-SP, Brasil Tel: 11-6462-6810 Fax: 11-6462-6829
J01.2
Application Note U15653EJ1V0AN
5
INTRODUCTION
Target Readers
This Application Note is intended for users who understand the functions of the 78K/IV Series microcontrollers, V800 Series
TM
microcontrollers, 78K/IV Series
CC78K4 C compiler (CC78K4), and RA78K4 assembler package (RA78K4). Purpose This Application Note explains the points to be noted and basic method of description when replacing a program described for the CC78K4 by the V850 Family CA850 C compiler package (CA850). Organization This Application Note consists of the following chapters. CHAPTER 1 OVERVIEW Compares the CC78K4, RA78K4, and CA850. CHAPTER 2 C LANGUAGE Explains how to replace compiler-dependent description in C language from CC78K4 to CA850. CHAPTER 3 ASSEMBLY LANGUAGE Explains how to replace assembler control instructions and quasi-directives from RA78K4 to CA850. CHAPTER 4 LINK DIRECTIVES Explains how to replace link directives from CC78K4 to CA850. CHAPTER 5 TRANSLATION LIMIT Explains the maximum performance of the CC78K4, RA78K4, and CA850. This Application Note does not explain instructions. For details of instructions, refer to the manual of each microcontroller. How to Read This Manual Read this Application Note from CHAPTER 1 OVERVIEW. If your program is not described in C language, you may skip CHAPTER 2 C LANGUAGE. If your program is not described in assembler language, you may skip CHAPTER 3 ASSEMBLY LANGAUGE. To change a link directive file, read CHAPTER 4 LINK DIRECTIVES. Conversions [ ]: " ": [CC78K4]: [RA78K4]: [CA850]: May be omitted. Reference destination Function and description format in CC78K4 Function and description format in RA78K4 Function and description format in CA850
: Description example
6
Application Note U15653EJ1V0AN
Related Documents
When using this Application Note, also refer to the following related documents. The related documents indicated in this publication may include preliminary versions. However, preliminary versions are not marked as such.
Documents Related to 78K/IV Series (User's Manuals)
Document Name IE-78K4-NS RA78K4 Assembler Package Operation Language Structured Assembler Preprocessor CC78K4 C Compiler Operation Language SM78K4 System Simulator Ver. 1.40 or Later Windows Based SM78K Series System Simulator Ver. 1.40 or Later
TM
Document No. U13356E U11334E U11162E U11743E
U11572E U11571E U10093E U10092E
Reference External Part User Open Interface Specifications Operation
ID78K Series Integrated Debugger Ver. 2.30 or Later Windows Based ID78K4 Integrated Debugger Windows Based RX78K4 Real-Time OS
U15185E
Reference Basics Installation
U10440E U10603E U10604E
Application Note U15653EJ1V0AN
7
Documents Related to V850 Family (User's Manuals) (Hardware Tools)
Document Name IE-703002-MC (In-Circuit Emulator for V851TM, V852TM, V853TM, V854TM, V850/SA1TM, V850/SB1TM, V850/SB2TM, V850/SV1TM, V850/SF1TM) IE-703003-MC-EM1 (In-Circuit Emulator Option Board for V853) IE-703008-MC-EM1 (In-Circuit Emulator Option Board for V854) IE-703017-MC-EM1 (In-Circuit Emulator Option Board for V850/SA1) IE-703037-MC-EM1 (In-Circuit Emulator Option Board for V850/SB1, V850/SB2) IE-703040-MC-EM1 (In-Circuit Emulator Option Board for V850/SV1) IE-703079-MC-EM1 (In-Circuit Emulator Option Board for V850/SF1) IE-703102-MC (In-Circuit Emulator for V850E/MS1 , V850E/MS2 ) IE-703102-MC-EM1 (In-Circuit Emulator Option Board for V850E/MS1, V850E/MS2) IE-703102-MC-EM1-A (In-Circuit Emulator Option Board for V850E/MS1) IE-V850E-MC (In-Circuit Emulator for V850E/IA1TM, V850E/IA2TM) IE-V850E-MC-A (In-Circuit Emulator for V850E1 (NB85E Core), V850E/MA1TM, V850E/MA2TM) IE-V850E-MC-EM1-A (In-Circuit Emulator Option Board for V850E1 (NB85E Core)) IE-V850E-MC-EM1-B, IE-V850E-MC-MM2 (In-Circuit Emulator Option Board for V850E1 (NB85E Core)) IE-703107-MC-EM1 (In-Circuit Emulator Option Board for V850E/MA1, V850E/MA2) IE-703116-MC-EM1 (In-Circuit Emulator Option Board for V850E/IA1) IE-703114-MC-EM1 (In-Circuit Emulator Option Board for V850E/IA2)
TM TM
Document No. U11595E
U11596E U12420E U12898E U14151E U14337E U15447E U13875E U13876E
U14487E
To be prepared U14482E
U14481E U14700E To be prepared
8
Application Note U15653EJ1V0AN
Documents Related to V850 Family (User's Manuals) (Software Tools)
Document Name CA850 C Compiler Package Ver. 2.40 or Later Operation C Language Project Manager Assembly Language ID850 Integrated Debugger Ver. 2.40 Windows Based ID850NW Integrated Debugger Ver. 1.10 or Later Windows Based SM850 System Simulator Ver. 2.40 Windows Based SM850 System Simulator Ver. 2.00 or Later Operation Operation Operation External Part User Open Interface Specifications Basics Installation Technical RX850 Pro Real-Time OS Ver. 3.13 Basics Installation Technical RD850 Task Debugger Ver. 3.01 RD850 Pro Task Debugger Ver. 3.01 AZ850 System Performance Analyzer Ver. 3.0 PG-FP3 Flash Memory Programmer CA850 C Compiler Package Ver. 2.40 (Application Note) V800 Series Development Tools (32 bits) Ver. 2.40 Windows Based (Application Note) Guide to Porting from CC78K4 to CA850 (Application Note) Coding Technique Tutorial Guide Document No. U15024E U15025E U15026E U15027E To be prepared U14891E To be prepared U14873E
RX850 Real-Time OS Ver. 3.13 or Later
U13430E U13410E U13431E U13773E U13774E U13772E U13737E U13916E U14410E U13502E U15184E U15196E
This manual
Application Note U15653EJ1V0AN
9
CONTENTS
CHAPTER 1 OVERVIEW .........................................................................................................................15 1.1 Product Form..............................................................................................................................15 1.2 Package Software.......................................................................................................................16 CHAPTER 2 C LANGUAGE ...................................................................................................................18 2.1 Compiler-Defined Macros..........................................................................................................18 2.2 #pragma Directive ......................................................................................................................19
2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 Use of special function register name (peripheral function register name) ....................................20 Description of assembler instruction ..............................................................................................20 Interrupt function............................................................................................................................22 Specification of interrupt disabled function.....................................................................................24 Control of interrupt disabling ..........................................................................................................25 CPU control instructions ................................................................................................................26 Absolute address access ...............................................................................................................27 Change of section name ................................................................................................................29 Change of module name................................................................................................................30
2.2.10 Specification of inline expansion....................................................................................................30 2.2.11 Use of rotate function.....................................................................................................................31 2.2.12 Use of multiplication function .........................................................................................................34 2.2.13 Use of division function ..................................................................................................................35 2.2.14 Use of data insertion function ........................................................................................................35 2.2.15 Specification of interrupt handler supporting real-time OS.............................................................36 2.2.16 Specification of real-time OS function............................................................................................37 2.2.17 Specification of device type ...........................................................................................................37 2.2.18 Structure packing...........................................................................................................................38
2.3
Extended Descriptions ..............................................................................................................38
2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 callt function...................................................................................................................................39 Register variables ..........................................................................................................................39 Using saddr area ...........................................................................................................................40 noauto function ..............................................................................................................................41 norec function ................................................................................................................................41 Bit type variable .............................................................................................................................42 Bit access ......................................................................................................................................43 callf function...................................................................................................................................44 Binary constant ..............................................................................................................................45
2.3.10 Specification of interrupt level ........................................................................................................46 2.3.11 Pascal function ..............................................................................................................................46
2.4
Size and Alignment Conditions of Variables...........................................................................47
2.4.1 2.4.2 Size of variable type ......................................................................................................................47 Alignment conditions......................................................................................................................48 Setting module name and loading include file................................................................................51 Setting library switch......................................................................................................................51 Defining symbols ...........................................................................................................................51 Reserving area for library...............................................................................................................52
Application Note U15653EJ1V0AN
2.5
Startup Routine (Startup Module).............................................................................................50
2.5.1 2.5.2 2.5.3 2.5.4
10
2.5.5 2.5.6 2.5.7 2.5.8 2.5.9
Reserving stack area..................................................................................................................... 53 Setting reset vector........................................................................................................................ 53 Setting location .............................................................................................................................. 53 Setting register bank...................................................................................................................... 54 Setting stack pointer ...................................................................................................................... 54
2.5.10 Setting general-purpose registers.................................................................................................. 54 2.5.11 Setting special registers ................................................................................................................ 55 2.5.12 Calling hardware initialization function........................................................................................... 55 2.5.13 Setting default value of standard library ........................................................................................ 56 2.5.14 ROMization processing ................................................................................................................. 56 2.5.15 Initializing variable area without default value ............................................................................... 58 2.5.16 Calling main function ..................................................................................................................... 59 2.5.17 Calling exit function ....................................................................................................................... 59 2.5.18 Defining segment (section)............................................................................................................ 60
2.6
Segment (Section) Output by Compiler...................................................................................61
2.6.1 2.6.2 Segment Output by CC78K4 ......................................................................................................... 61 Section output by CA850............................................................................................................... 62
2.7
Library and Header File .............................................................................................................63
CHAPTER 3 ASSEMBLY LANGUAGE .................................................................................................65 3.1 Segment Quasi-Directive (Section Definition Quasi-Directive).............................................68
3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 CSEG, .text, .const, .sconst........................................................................................................... 68 DSEG, .bss, .data, .sbss, .sdata, .sebss, .sedata, .sibss, .sidata, .tibss, .tidata, .tibss.byte, .tidata.byte, .tibss.word, .tidata.word ............................................................................................. 70 BSEG ............................................................................................................................................ 75 .previous, .section.......................................................................................................................... 76 ORG, .org ...................................................................................................................................... 77 .align.............................................................................................................................................. 78 EQU............................................................................................................................................... 79 SET, .set........................................................................................................................................ 79 .size, .frame, .file ........................................................................................................................... 80 NAME ............................................................................................................................................ 81
3.2
Symbol Definition Quasi-Directives (Symbol Control Quasi-Directives) .............................78
3.2.1 3.2.2 3.2.3
3.3 3.4
Object Module Name Declaration Quasi-Directives ...............................................................80
3.3.1
Memory Initialization and Area Reservation Quasi-Directives (Area Reservation Quasi-Directives) .......................................................................................................................81
3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 DB, .byte........................................................................................................................................ 81 DW, .hword.................................................................................................................................... 82 DG ................................................................................................................................................. 83 .word.............................................................................................................................................. 84 .space............................................................................................................................................ 84 .shword.......................................................................................................................................... 85 DS, .lcomm .................................................................................................................................... 85 DBIT .............................................................................................................................................. 86 .float, .str........................................................................................................................................ 87 PUBLIC, .globl ............................................................................................................................... 87 EXTRN, .extern ............................................................................................................................. 88
Application Note U15653EJ1V0AN
3.5
Linkage Quasi-Directives (Program Linkage Quasi-Directives) ...........................................87
3.5.1 3.5.2
11
3.5.3 3.5.4
EXTBIT ..........................................................................................................................................89 .comm ............................................................................................................................................89 BR, CALL.......................................................................................................................................90 RSS ...............................................................................................................................................91 MACRO, .macro ............................................................................................................................92 LOCAL, .local.................................................................................................................................93 REPT, .repeat ................................................................................................................................94 IRP, .irepeat...................................................................................................................................95 EXITM, .exitm, .exitma...................................................................................................................96 ENDM, .endm ................................................................................................................................98 END ...............................................................................................................................................98
3.6 3.7 3.8
Automatic Selection Quasi-Directives .....................................................................................90
3.6.1 3.7.1 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6
General-Purpose Register Selection Quasi-Directive ............................................................91 Macro Quasi-Directives (Macro, Skip, Repeat Assemble Quasi-Directives)........................92
3.9
Assemble End Quasi-Directive .................................................................................................98
3.9.1
3.10 Assembler Target Model Specification Control Instructions (Assembler Control Quasi-Directives) .....................................................................................99
3.10.1 $PROCESSOR, .option .................................................................................................................99
3.11 Debug Information Output Control Instructions...................................................................100
3.11.1 $DEBUG, $NODEBUG, $DEBUGA, $NODEBUGA.....................................................................100
3.12 Cross-Reference List Output Specification Control Instructions .......................................100
3.12.1 $XREF, $NOXREF, $SYMLIST, $NOSYMLIST ..........................................................................100
3.13 Include Control Instructions (File Input Control Quasi-Directives) ....................................101
3.13.1 $INCLUDE, .include.....................................................................................................................101 3.13.2 .binclude ......................................................................................................................................101
3.14 Assemble List Control Instructions .......................................................................................102
3.14.1 $EJECT, $TITLE, $SUBTITLE, $LIST, $NOLIST, $GEN, $NOGEN, $COND, $NOCOND, $FORMFEED, $NOFORMFEED, $WIDTH, $LENGTH, $TAB ....................................................102
3.15 Conditional Assembly Control Instructions (Conditional Assembly Quasi-Directives) ...103
3.15.1 $SET, $RESET............................................................................................................................103 3.15.2 $IF, .ifdef......................................................................................................................................104 3.15.3 .ifndef ...........................................................................................................................................104 3.15.4 $_IF, .if.........................................................................................................................................105 3.15.5 .ifn................................................................................................................................................105 3.15.6 $ELSEIF, $_ELSEIF, .elseif.........................................................................................................106 3.15.7 .elseifn .........................................................................................................................................107 3.15.8 $ELSE, .else ................................................................................................................................107 3.15.9 $ENDIF, .endif .............................................................................................................................108
3.16 SFR Area Change Control Instructions .................................................................................108
3.16.1 $CHGSFR, $CHGSFRA ..............................................................................................................108
CHAPTER 4 LINK DIRECTIVES ..........................................................................................................109 4.1 Contents of Link Directive.......................................................................................................109 4.2 Description of Link Directive ..................................................................................................110 CHAPTER 5 TRANSLATION LIMIT .....................................................................................................113 APPENDIX INDEX ..................................................................................................................................114 12
Application Note U15653EJ1V0AN
LIST OF FIGURES
Figure No. 1-1 2-1 2-2
Title
Page
Development Procedure ................................................................................................................................ 17 RAM Image of Example 1.............................................................................................................................. 49 RAM Image of Example 2.............................................................................................................................. 50
Application Note U15653EJ1V0AN
13
LIST OF TABLES
Table No. 1-1 1-2 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 2-9 3-1 4-1 5-1
Title
Page
Product Name ................................................................................................................................................15 Package Software..........................................................................................................................................16 Compiler-Defined Macros ..............................................................................................................................18 #pragma Directives ........................................................................................................................................19 Extended Descriptions ...................................................................................................................................38 Differences in Size of Type ............................................................................................................................47 Alignment Conditions (CC78K4) ....................................................................................................................48 Alignment Conditions (CA850).......................................................................................................................48 Segments Output by CC78K4........................................................................................................................61 Sections Output by CA850.............................................................................................................................62 Library and Header File .................................................................................................................................63 Quasi-Directives and Control Instructions......................................................................................................65 Link Directives .............................................................................................................................................109 Translation Limit Value ................................................................................................................................113
14
Application Note U15653EJ1V0AN
CHAPTER 1 OVERVIEW
This chapter gives an outline of the CC78K4, RA78K4, and CA850.
1.1 Product Form
The C compiler, CC78K4, and assembler and linker, RA78K4, are separated for the 78K/IV Series. In contrast, the C compiler, assembler, and linker for the V850 Family are combined into one package, the CA850. Table 1-1. Product Name
78K/IV Series C compiler package Assembler package USxxxxCC78K4 USxxxxRA78K4 V850 Family USxxxxCA703000
Note, however, that the device file for both the 78K/IV Series and V850 Family must be purchased separately.
Application Note U15653EJ1V0AN
15
CHAPTER 1 OVERVIEW
1.2 Package Software
The CC78K4, RA78K4, and CA850 include the following programs. Table 1-2. Package Software
NameNote C compiler Assembler Linker ROMization processor Object converter Hex converter Librarian Archiver Structured assembler List converter Dump directive Disassembler Section file generator Performance checker Cross-reference tool Memory layout visualization tool CC78K4, RA78K4 cc78k4 ra78k4 lk78k4 - oc78k4 CA850 ca850 as850 ld850 romp850 hx850
lb78k4
ar850
st78k4 lcnv78k4 - - - - - -
- - dump850 dis850 sf850 pc850 cxref rammap
Note When two names are given, the name on the top is the one used in the RA78K4 and the name on the bottom is the one used in the CA850.
16
Application Note U15653EJ1V0AN
CHAPTER 1 OVERVIEW
The development procedure of each program is as illustrated below. Figure 1-1. Development Procedure
CC78K4/RA78K4 CA850
C source file
Structured assemble source file
C source file
cc78k4
st78k4
ca850
Assemble source file
Assemble source file
ra78k4
as850
Object
Object
lk78k4
ld850
Load module
Load module
romp850
ROMization module
oc78k4
hx850
Hex code
Hex code
lb78k4
ar850
lcnv78k4 dump850
dis850
sf850
pc850
cxref
rammap
Application Note U15653EJ1V0AN
17
CHAPTER 2 C LANGUAGE
This chapter explains the points to be noted when rewriting a C source program for the CC78K4 into a program for the CA850, and how to describe the program. The CC78K4 and CA850 conform to the ANSI-C
Note
Standard.
Note ANSI stands for American National Standards Institute
2.1 Compiler-Defined Macros
The following macros are defined in advance for the CC78K4 and CA850. Table 2-1. Compiler-Defined Macros
CC78K4, RA78K4 __LINE__ __FILE__ __DATE__ __TIME__ __STDC__ CA850 Contents Line number of current source Source file name Date of compiling source file ("mm dd yyyy") Time of compiling source file ("hh:mm:ss") 1 in decimal numbers (CC78K4: Defined when -ZA option is specified CA850: Defined when -ansi option is specified) __v850 __v850__ CPU macro __4038_ __3003__ 1 in decimal numbers (macro indicating series name of devices) 1 in decimal numbers (macro indicating CPU of target) Examples of PD784038 and PD703003 are shown.
__K4__
By using these compiler-defined macros, descriptions for the CC78K4 and those for the CA850 can exist together in a C source program.
#ifdef __K4__ #pragma sfr #endif #ifdef __v850__ # pragma ioreg #endif
/* Description for CC78K4 */
/* Description for CA850 */
18
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
2.2 #pragma Directive
The #pragma directives instruct the compiler to run using the method defined by the compiler. The CC78K4 and CA850 have the following #pragma directives. Table 2-2. #pragma Directives
No. 1 2 Function Use of special function register name Description of assembler instruction #pragma sfr #pragma asm CC78K4 #pragma ioreg #pragma asm #pragma endasm #pragma interrupt CA850
3
Interrupt function
#pragma vect #pragma interrupt Interrupts are disabled before preprocessing if DI(); is described at the beginning of a functionNote. #pragma di #pragma ei #pragma halt #pragma stop #pragma nop #pragma brk #pragma access #pragma section
4
Specification of interrupt disabled function
#pragma block_interrupt
5
Control of interrupt disabling (DI/EI)
#pragma directive is not necessary.
6
CPU control instructions
#pragma directive is not provided. Description using assembler instruction
7 8
Absolute address access Change of section name
None #pragma section #pragma text None #pragma inline None None None #pragma directive is not provided. Description by assembler instruction #pragma directive is not provided. Description by assembler instruction #pragma rtos_task #pragma cpu #pragma pack
9 10 11 12 13 14
Change of module name Specification of inline expansion Use of rotate function Use of multiplication function Use of division function Use of data insertion function
#pragma name None #pragma rot #pragma mul #pragma div #pragma opc
15
Specification of interrupt handler supporting real-time OS Specification of real-time OS function Specification of device type Structure packing
#pragma rtos_interrupt
16 17 18
#pragma rtos_task #pragma pc None
Note To describe DI();, the #pragma di directive is necessary.
Application Note U15653EJ1V0AN
19
CHAPTER 2 C LANGUAGE
2.2.1 Use of special function register name (peripheral function register name) To rewrite a description for the CC78K4 into one for the CA850, change "sfr" to "ioreg". [CC78K4] Using the #pragma directive, declare that a special function register name is used in the C source. #pragma sfr [CA850] Using the #pragma directive, declare that a peripheral function register name is used in the C source. #pragma ioreg 2.2.2 Description of assembler instruction There are two ways to describe assembler instructions in the C source program, for both the CC78K4 and CA850. [CC78K4] (1) To insert one line Declare use of _asm using the #pragma directive. #pragma asm Describe the assembler instruction in the C source in the following format. _asm (character string literal);
#pragma asm void main(void) { __asm("\tMOV\tA,B"); }
(2) To insert two or more lines Indicate the start of the assembler instruction by #asm, and the end by #endasm. Then, describe the assembler instruction between #asm and #endasm. #asm assembler instruction #endasm
#asm MOV #endasm A,B
20
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
[CA850] (1) To insert one line Describe the assembler instruction in the C source in the following format. __asm (character string constant); or, _asm (character string constant); When specifying the -ansi option, however, use the __asm format.
__asm("\tmov\tr10,r11");
(2) To insert two or more lines Indicate the start of the assembler instruction by #pragma asm, and the end by #pragma endasm. Then, describe the assembler instruction between #pragma asm and #pragma endasm. #pragma asm assembler instruction #pragma endasm
#pragma asm mov #pragma endasm r10,r11
Application Note U15653EJ1V0AN
21
CHAPTER 2 C LANGUAGE
2.2.3 Interrupt function When defining an interrupt function using the #pragma directive, the address of the interrupt function is output to an interrupt vector (handler) in the case of the CC78K4, and a branch instruction to the interrupt function is output to an interrupt vector (handler) in the case of the CA850. When replacing a description for the CC78K4 with one for the CA850, note the differences in interrupt request names (which differ depending on the microcontroller). [CC78K4] Use the #pragma directive to specify an interrupt request name, function name, stack selection, register, and saving/restoring the saddr2 area to be used. #pragma vect interrupt request name function name [, stack selection specification] stack use specification [{specification without change}] register bank specification or, #pragma interrupt interrupt request name function name [, stack selection specification] stack use specification [{specification without change}] register bank specification Two types of interrupt function qualifiers are available. Non-maskable/maskable interrupt function __interrupt function definition or function declaration Software interrupt function __interrupt_brk function definition or function declaration
#pragma interrupt INTP0 int1 #pragma vect INTP1 int2 sp=buff+10 RB1 #pragma interrupt BRK_I int_b RB2
__interrupt void int1(void) { ... } __interrupt void int2(void) { ... } __interrupt_brk void int_b(void) { ... }
22
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
[CA850] Specify an interrupt request name, function name, and placement method using the #pragma directive. #pragma interrupt interrupt request name function name [placement method] The interrupt function qualifier is as follows. __interrupt function definition or function declaration However, the qualifier is as follows for multiple interrupts. __multi_interrupt function definition or function declaration
#pragma interrupt INTP110 int1 #pragma interrupt INTP111 int2 direct #pragma interrupt INTP112 int3
__interrupt void int1(void) { ... } __interrupt void int2(void) { ... } __multi_interrupt void int3(void) { ... }
Application Note U15653EJ1V0AN
23
CHAPTER 2 C LANGUAGE
2.2.4 Specification of interrupt disabled function The entire function is disabled from being interrupted. When porting from the CC78K4 to the CA850, specify the name of the function to be disabled from being interrupted using the #pragma directive, instead of using the interrupt functions DI() and EI(). [CC78K4] Interrupts are disabled before preprocessing if DI() is described at the beginning of a function.
#pragma DI #pragma EI
void func1(void) { DI(); ... EI(); }
[CA850] Specify a function name using the #pragma directive. #pragma block_interrupt function name
#pragma block_interrupt func1 void func1(void) { ... }
24
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
2.2.5 Control of interrupt disabling Interrupt functions are provided in both the CC78K4 and CA850. To use these functions in the CC78K4, however, the #pragma directive is necessary. The directive is not necessary in the CA850. [CC78K4] Specify that DI() and EI() are used as interrupt functions using the #pragma directive. #pragma di #pragma ei Describe the functions in the C source in the same manner as calling a function. DI(); EI();
#pragma DI #pragma EI
void func2(void) { ... DI(); ... EI(); ... }
[CA850] A function to control interrupt disabling is provided. The #pragma directive is not necessary. __DI(); __EI();
void func2(void) { ... __DI(); ... __EI(); ... }
Application Note U15653EJ1V0AN
25
CHAPTER 2 C LANGUAGE
2.2.6 CPU control instructions The CC78K4 has CPU control instructions that control the CPU on the C source program (HALT, STOP, BRK, and NOP). The CA850 does not have such instructions. Describe assembler instructions instead. [CC78K4] Using the #pragma directive, specify that the HALT(), STOP(), BRK(), and NOP() instructions are used as interrupt functions. #pragma halt #pragma stop #pragma brk #pragma nop Describe the instructions in the C source in the same manner as calling a function. HALT(); STOP(); BRK(); NOP();
#pragma HALT #pragma STOP #pragma BRK #pragma NOP
HALT(); STOP(); BRK(); NOP();
[CA850] No CPU control instructions are available. Describe assembler instructions. halt, trap, nop
__asm("\thalt"); __asm("\ttrap\t0x00"); __asm("\tnop");
26
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
2.2.7 Absolute address access The CC78K4 has a function for accessing absolute addresses. The CA850 does not have such a function. Access absolute addresses using a pointer. [CC78K4] Using the #pragma directive, specify that a function for absolute address access is used. #pragma access Describe the function in the C source in the same manner as calling a function. The names of the functions for accessing absolute addresses are the following four. peekb: Returns 1 byte of the contents of the address of the argument. peekw: Returns 2 bytes of the contents of the address of the argument. pokeb: Writes 1 byte to the address of the argument. pokew: Writes 2 bytes to the address of the argument.
#pragma access
int char
data1,data2; cdata1,cdata2;
cdata1 = peekb ( 0x1234 ); data1 = peekw ( 0x1234 ); pokeb ( 0xfe20 , 5 ); pokew ( 0xfe20 , 0xffff );
[CA850] No function for accessing absolute addresses is available. Use a pointer as shown below. Also use the sample in Example 2 for reference.
int char char int data1,data2; cdata1,cdata2; *p; *q;
cdata1 = *((char *)0x1234); data1 = *((int *)0x1234);
p = (char *)0xffe000; *p = 5; q = (int *)0xffe000; *q = 0xffff;
Application Note U15653EJ1V0AN
27
CHAPTER 2 C LANGUAGE

unsigned char peekb(unsigned int); unsigned short peekh(unsigned int); unsigned int peekw(unsigned int);
void pokeb(unsigned int,unsigned char); void pokeh(unsigned int,unsigned short); void pokew(unsigned int,unsigned int);
unsigned char peekb(unsigned int adr) { return *((unsigned char *)adr); }
unsigned short peekh(unsigned int adr) { return *((unsigned short *)adr); }
unsigned int peekw(unsigned int adr) { return *((unsigned int *)adr); }
void pokeb(unsigned int adr,unsigned char val) { unsigned char *p;
p = (unsigned char *)adr; *p = val; }
void pokeh(unsigned int adr,unsigned short val) { unsigned short *p;
p = (unsigned short *)adr; *p = val; }
void pokew(unsigned int adr,unsigned int val) { unsigned int *p;
p = (unsigned int *)adr; *p = val; }
28
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
2.2.8 Change of section name Although section of the #pragma directive is the same, the character string to be specified after that differs. [CC78K4] Specify the section name to be changed, a new section name, and the start address of the section using the #pragma directive. #pragma section compiler output section name section name to be changed [AT start address]
#pragma section @@CODE CODESEG /* Changes segment name @@CODE to CODESEG */ #pragma section @@DATA DATASEG AT 0FFE10H /* Changes segment name @@DATA to DATASEG and allocates it to address 0FFE10H */
[CA850] Using the #pragma directive, specify a section name for data or a module. If no section name is specified, the default section name is assumed. Data #pragma section section type ["section name"] begin declaration of variable/constant #pragma section section type ["section name"] end Module #pragma text ["section name"] [function name] Allocation can be specified for the following data section types. .tidata (.tidata section, .tibss section) .data (.data section, .bss section) .sdata (.sdata section, .sbss section) .sedata (.sedata section, .sebss section) .sidata section (.sidata section, .sibss section) .sconst section .const section A section name can be specified for the following section types. .data (.data section, .bss section) .sdata (.sdata section, .sbss section) .const section .sconst section
Application Note U15653EJ1V0AN
29
CHAPTER 2 C LANGUAGE

#pragma section sconst begin const int const_data=10; #pragma section sconst end /* Allocates const_data variable to .sconst section */ #pragma section data "d1sec" begin int data_data; #pragma section data "d1sec" end /* Allocates data_data variable to dlsec.bss section of data attribute */
#pragma text "f1sec" func1 /* Allocates func1 function to flsec.text section */
2.2.9 Change of module name A module name cannot be changed in the CA850. [CC78K4] Specify a module name using the #pragma directive. #pragma name module name
#pragma name new_name
[CA850] Not provided 2.2.10 Specification of inline expansion With the CC78K4, a user-defined function cannot be expanded inline. With the CA850, inline expansion of a user function can be specified by the #pragma directive. [CC78K4] Not provided [CA850] Using the #pragma directive, specify inline expansion of each function. #pragma inline function name [,function name...]
#pragma inline func
30
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
2.2.11 Use of rotate function The V850 Family does not have an instruction that rotates data. Therefore, the CA850 does not have a rotate function. To rotate data, create an assembler program by referring to the example below. [CC78K4] Using the #pragma directive, specify that a code to be rotated is directly expanded inline and output, instead of calling a function. #pragma rot Describe the function name in the C source in the same manner as calling a function. The rotate function names are the following four. rorb rolb rorw rolw
#pragma rot
ucdata3 = rorb(ucdata1,ucdata2); ucdata3 = rolb(ucdata1,ucdata2); uidata3 = rorw(uidata1,ucdata2); uidata3 = rolw(uidata1,ucdata2);
[CA850] No rotate function is available. To rotate a variable, create a program by referring to the sample below. However, inline expansion is not executed. Prototype declaration in C source
unsigned char rorb(unsigned char,unsigned char); unsigned char rolb(unsigned char,unsigned char); unsigned short rorh(unsigned short,unsigned char); unsigned short rolh(unsigned short,unsigned char); unsigned int rorw(unsigned int,unsigned char); unsigned int rolw(unsigned int,unsigned char);
Application Note U15653EJ1V0AN
31
CHAPTER 2 C LANGUAGE
Assembler description (1/2)
.globl .globl .globl .globl .globl .globl _rorb _rolb _rorh _rolh _rorw _rolw
.file "rot.s" .text -- 1byte variable rotation -.align 4 _rorb: shr 1,r6 bnc rorb1 or 0x00000080,r6 rorb1: add -1,r7 mov r6,r10 bnz _rorb jmp[lp] .align _rolb: add rolb1: shl st.h tst1 bz or rolb2: add mov rolb1 4,sp -1,r7 r6,r10 1,r6 r6,[sp] 0,1[sp] rolb2 0x00000001,r6 -4,sp 4
bnz add jmp[lp]
-- 2byte variable rotation -.align 4 _rorh: shr 1,r6 bnc rorh1 or 0x00008000,r6 rorh1: add -1,r7 mov r6,r10 bnz _rorh jmp[lp] .align _rolh: add -4,sp 4
32
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
Assembler description (2/2)
rolh1: shl st.w tst1 or rolh2: add mov bnz jmp[lp] -1,r7 r6,r10 rolh1 add 4,sp r6,[sp] 0,2[sp] bz rolh2 0x00000001,r6 1,r6
-- 4byte variable rotation -.align _rorw: shr bnc or rorw1: add mov bnz jmp[lp] .align _rolw: shl bnc or rolw1: add mov bnz jmp[lp] -1,r7 r6,r10 _rolw 1,r6 rolw1 0x00000001,r6 4 -1,r7 r6,r10 _rorw rorw1 0x80000000,r6 1,r6 4
Application Note U15653EJ1V0AN
33
CHAPTER 2 C LANGUAGE
2.2.12 Use of multiplication function The CA850 does not have a multiplication function. Describe multiplication using the value of an expression. [CC78K4] Using the #pragma directive, specify that a code to be multiplied is directly expanded inline and output, instead of calling a function. #pragma mul Describe the function name in the C source in the same manner as calling a function. The multiplication function names are the following three. mulu muluw mulw
#pragma mul uidata3 = mulu(ucdata1,ucdata2); uldata3 = muluw(uidata1,uidata2); ldata3 = mulw(idata1,idata2);
[CA850] No function for inline expansion is available. Describe multiplication in the form of an expression (* operator), not in the form of a function. Be careful of the size of the argument assigned as the argument of muluw or mulw because int type and long type are 4 bytes (int type must be short type).
34
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
2.2.13 Use of division function The CA850 does not have a division function. Describe division using the value of an expression. [CC78K4] Using the #pragma directive, specify that a code to be divided is directly expanded inline and output, instead of calling a function. #pragma div Describe the function name in the C source in the same manner as calling a function. The division function names are the following two. divuw moduw
#pragma div uidata3 = divuw(uidata1,ucdata2); ucdata3 = moduw(uidata1,ucdata2);
[CA850] No function for inline expansion is available. Describe division in the form of an expression (/operator or %operator), not in the form of a function. 2.2.14 Use of data insertion function The CA850 does not have a data insertion function. Describe data insertion using the assembler. [CC78K4] Using the #pragma directive, specify use of a function for data insertion. #pragma opc Describe the function in the C source in the same manner as calling a function. __OPC (data value [, data value ...]
#pragma opc
__OPC(0xBF,0x12);
[CA850] No function for data insertion is available. Describe data insertion using an assembler quasi-directives.
__asm(".byte 0xBF,0x12");
Application Note U15653EJ1V0AN
35
CHAPTER 2 C LANGUAGE
2.2.15 Specification of interrupt handler supporting real-time OS With the CA850, a directly activated interrupt handler cannot be described in C language. It must be described using the assembler. [CC78K4] Using the #pragma directive, specify an interrupt request name, function name, and stack selection. #pragma rtos_interrupt interrupt function name function name [,stack selection specification] The interrupt function qualifier is as follows. Non-maskable/maskable interrupt function __rtos_interrupt function definition or function declaration
#pragma rtos_interrupt INTP3 int4 sp=buff+10 __rtos_interrupt void int4(void) { ... ret_int(); }
[CA850] No #pragma directive is available. The handler must be described using the assembler. The RX850 and RX850 Pro have macros for directly activated interrupt handlers. Describe a directly activated interrupt handler as illustrated below. The RX850 and RX850 Pro have more than one method of description, depending on the return processing. For details, refer to the user's manual of the real-time OS. Return by reti in RX850
#include "stdrx.inc" .section jr _inthdr " INTP123"
.text .align 4 .globl _inthdr: RTOS_IntEntry ... RTOS_IntExit _inthdr
36
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
2.2.16 Specification of real-time OS function The description format is the same in the CC78K4 and CA850. [CC78K4] Using the #pragma directive, the function name specified is interpreted as a task for the real-time OS. #pragma rtos_task task function name [CA850] Using the #pragma directive, the function name specified is interpreted as a task for the real-time OS. #pragma rtos_task task function name There is no difference between the CC78K4 and CA850.
#pragma rtos_task func4 void func4(void) { ... ext_tsk(); }
2.2.17 Specification of device type To replace a description for the CC78K4 with one for the CA850, change "pc" to "cpu". When specifying a device, use a blank instead of parentheses. [CC78K4] Specify a device type using the #pragma directive. #pragma pc (device type)
#pragma pc(4038)
[CA850] Specify a device type using the #pragma directive. #pragma cpu device type
#pragma cpu 3003
Application Note U15653EJ1V0AN
37
CHAPTER 2 C LANGUAGE
2.2.18 Structure packing The CC78K4 does not have a structure packing function. Structures are justified and an area is reserved. [CC78K4] Not provided [CA850] The value specified by the #pragma directive is used as the current packing value. The specified value is valid until the next #pragma pack directive appears. #pragma pack (packing value)
#pragma pack(1) struct{ char data1; short data2; char data3; }
2.3 Extended Descriptions
Extended descriptions are used to realize functions peculiar to a device. The extended descriptions of the CC78K4 and CA850 are as follows. Table 2-3. Extended Descriptions
No. 1 2 3 4 5 6 7 8 9 10 11 Function callt function Register variable Use of saddr area noauto function norec function Bit type variable Bit access callf function Binary constant Interrupt level Pascal function callt / __callt register sreg / __sreg / __sreg1 noauto norec bit/boolean / __boolean / __boolean1 Variable name. bit position callf / __callf 0bxxxxxxxx None __pascal CC78K4 None register None None None Bit field Union and bit field None 0bxxxxxxxx __set_il None CA850
38
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
2.3.1 callt function The CA850 has a callt instruction only for the V850E. However, use an ordinary function in the CA850. [CC78K4] callt/__callt stores the address of a function to be called in an area called callt (0x40 to 0x7f) to make it possible to call a function with a code shorter than that used to directly call the function. The callt instruction is used to call a function. The description format is as follows. callt type name function name __callt type name function name
callt void func(void) { ... }
[CA850] The V850E has a callt instruction, but the compiler uses the callt instruction only during the runtime of the prologue and epilogue of a function. Therefore, use an ordinary function.
void func(void) { ... }
2.3.2 Register variables A register variable is described in the same manner in both the CC78K4 and CA850, but a variable is allocated to a register differently. If optimization is specified in the CA850, even a variable declared by register may not be allocated to a register. [CC78K4] Variables declared by register are allocated to a register (RP3 or VP) or the saddr2 area. When the -ZO option is specified, the variables are allocated in the sequence in which they were declared. If the -ZO option is not specified, they are allocated in the order of the number of times they were referenced. The description format is as follows. register type name variable name
Application Note U15653EJ1V0AN
39
CHAPTER 2 C LANGUAGE
[CA850] Variables declared by register are allocated to registers for register variables in the sequence in which they were declared. If optimization is specified, however, a variable that has been referenced fewer times may not be allocated. The description format is as follows. register type name variable name
int func(void) { register int reg_a,reg_b; ... }
2.3.3 Using saddr area It is recommended to locate the saddr2 area of the 78K/IV Series to the .tidata/.tibss section of the CA850. The .tidata section can be accessed by a 2-byte instruction (sld/sst). [CC78K4] External variables declared by sreg or __sreg and static variables in a function are relocatable and automatically allocated to the saddr2 area. Variables declared by __sreg1 are relocatable and automatically allocated to the saddr1 area. The description format is as follows. sreg type name variable name __sreg type name variable name __sreg1 type name variable name
sreg intsreg_data0,sreg_data1,sreg_data2;
[CA850] Not provided. Using the #pragma section directive, allocate external variables to the .tidata/.tibss section of the internal RAM. #pragma section tidata #pragma section tidata
#pragma section tidata begin int sreg_data0,sreg_data1,sreg_data2;
begin end
type name variable name
#pragma section tidata end
40
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
2.3.4 noauto function The CA850 does not have a noauto function. Use an ordinary function. [CC78K4] The noauto function restricts an automatic variable from outputting a code for pre- and post-processing (creation of stack frame). The description format is as follows. noauto type name function name
noauto void func(void) { ... }
[CA850] No noauto function is available. Use an ordinary function.
void func(void) { ... }
2.3.5 norec function The CA850 does not have a norec function. Use an ordinary function. [CC78K4] A function that does not call an other function from itself can be used as a norec function. The norec function does not output a code for pre- and post-processing of a function (creation of stack frame). All arguments are allocated to the saddr2 area for register and norec function arguments. The description format is as follows. norec type name function name
norec void func(void) { ... }
Application Note U15653EJ1V0AN
41
CHAPTER 2 C LANGUAGE
[CA850] No norec function is available. Use an ordinary function.
void func(void) { ... }
2.3.6 Bit type variable The CA850 cannot define bit type variables. Describe them by using a bit field. [CC78K4] bit, boolean, and __boolean type variables are treated as 1-bit data and allocated to the saddr2 area. The __boolean1 type variable is treated as 1-bit data and allocated to the saddr1 area. bit, boolean, __boolean, and __boolean1 type variables are treated in the same manner as an external variable without a default value (undefined). The description format is as follows. bit variable name boolean variable name __boolean variable name __boolean1 variable name
boolean bit1,bit2,bit3; void func(void) { bit1 = 1; bit2 = bit3; }
42
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
[CA850] Not provided. Use a bit field. struct{ unsigned char unsigned char unsigned char unsigned char unsigned char unsigned char unsigned char unsigned char };
struct bitf{ unsigned int bit1:1; unsigned int bit2:1; unsigned int bit3:1; }bitfield;
f0:1; f1:1; f2:1; f3:1; f4:1; f5:1; f6:1; f7:1;
void func(void) { bitfield.bit1 = 1; bitfield.bit2 = bitfeeld.bit3; }
2.3.7 Bit access The CA850 cannot define a bit access using a type variable. Use a bit field to describe a bit access. [CC78K4] The description format is as follows. variable name.bit position
unsigned char data; void func(void) { data = 0xff; data.1 = 0; }
Application Note U15653EJ1V0AN
43
CHAPTER 2 C LANGUAGE
[CA850] Not provided. Use a union and a bit field.
union{ unsigned char cdata; struct{ unsigned char bit0:1; unsigned char bit1:1; unsigned char bit2:1; unsigned char bit3:1; unsigned char bit4:1; unsigned char bit5:1; unsigned char bit6:1; unsigned char bit7:1; }bitfield; }data;
void func(void) { data.cdata = 0xff; data.bitfield.bit1 = 0; }
2.3.8 callf function The V850 Family does not have an instruction equivalent to the callt instruction. Use an ordinary function. [CC78K4] callf/__callf can call a function using the callf instruction with a code shorter than when using the call instruction. The description format is as follows. callf type name function name __callf type name function name
callf void func(void) { ... }
44
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
[CA850] No callf function is available. Use an ordinary function.
void func(void) { ... }
2.3.9 Binary constant The description format is the same in both the CC78K4 and CA850. [CC78K4] [CA850] Binary constants can be described where integer constants can be described. The description format is as follows. 0b binary constant 0B binary constant
ucdata1 = 0b00010001; ucdata2 = 0B11110000;
Application Note U15653EJ1V0AN
45
CHAPTER 2 C LANGUAGE
2.3.10 Specification of interrupt level The CA850 allows the description of an interrupt level specification. [CC78K4] Not provided [CA850] A function for controlling the interrupt level (INT level) is available. An integer value of -1 to 8 can be specified as the interrupt priority level. Specify an interrupt request name from the maskable interrupts defined in the device file under "interrupt request name". If -1 is specified as the interrupt priority level, acknowledgement of maskable interrupts is disabled. If 0 is specified, it is enabled. The description format is as follows. __set_il (interrupt priority level, "interrupt request name") The meaning of a value of the interrupt priority level is as follows. -1: 0: 1 to 8: Disables acknowledgement of maskable interrupts. Enables acknowledgement of maskable interrupts. Sets interrupt priority level 0 to 7.
Note that the specified value is the value of the level plus 1. When the priority level of the interrupt request name INTP110 is 1
__set_il(2,"INTP110");
2.3.11 Pascal function The CA850 does not have a Pascal function. Use an ordinary function. [CC78K4] The Pascal function generates a code to correct the stack used by piling up arguments when a function is called on the called function side, instead of on the function calling side. When a function is declared, the __pascal attribute is prefixed.
__pascal void func(void);
void func(void) { ... }
46
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
[CA850] No Pascal function is available. Use an ordinary function.
void func(void);
void func(void) { ... }
2.4 Size and Alignment Conditions of Variables
The CC78K4 and CA850 differ in the size of the area reserved by RAM and the alignment conditions of variables, even when the type is the same. 2.4.1 Size of variable type The differences in the size of the variable types in the CC78K4 and CA850 are as follows. Table 2-4. Differences in Size of Type
Type char short int
Note
CC78K4 1 byte 2 bytes 2 bytes 4 bytes 4 bytes 4 bytes 1 byte 2 bytes 4 bytes 4 bytes 4 bytes 4 bytes
CA850
long float double
Note Note that the size of the int type differs.
Application Note U15653EJ1V0AN
47
CHAPTER 2 C LANGUAGE
2.4.2 Alignment conditions The alignment conditions of variables differ in the CC78K4 and CA850 as follows. [CC78K4] Table 2-5. Alignment Conditions (CC78K4)
Option Default -RA option Byte boundary alignment 2-byte boundary alignment for external variables of 2 bytes or more (except variables allocated to saddr area) Alignment Condition
[CA850] Table 2-6. Alignment Conditions (CA850)
Type Basic type Size (unsigned) chart and its array (unsigned) short and its array Other basic types (including pointer) Union 2 bytes < size Size 2 bytes Structure 2 bytes < size Size 2 bytes If member of type greater than int type exists Size 2 bytes If member greater than int type does not exist and if 1 byte < size of type 2 bytes Size 2 bytes If member greater than int type does not exist and if size of type 1 byte Alignment Condition Byte boundary 2-byte boundary 4-byte boundary 4-byte boundary Maximum member size boundary 4-byte boundary 4-byte boundary
2-byte boundary
Byte boundary

struct ST0 { char int short int }ST0data; data00; data01; data02; data03;
48
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
The image on RAM is as shown below. Figure 2-1. RAM Image of Example 1
[CC78K4] [CA850]
0xxxx10
0xxxxxc
data03 Align hole (2 bytes)
0xxxxx8
data02
data03 0xxxxx4 data02 Align hole data01 0xxxxx0 data00 (3 bytes) data00 data01
Because the size of this structure includes an align hole, it is 7 bytes in the CC78K4 and 16 bytes in the CA850. The alignment condition of the structure is 1-byte alignment in the CC78K4 and 4-byte alignment in the CA850. The number of align holes can be decreased by defining the size of variables, starting from the greatest, as follows.
struct ST0 { int int short char }ST0data; data01; data03; data02; data00;
Application Note U15653EJ1V0AN
49
CHAPTER 2 C LANGUAGE
The image on RAM is as shown below. Figure 2-2. RAM Image of Example 2
[CC78K4] [CA850]
0xxxx10
0xxxxxc Align hole (1 byte) data00
0xxxxx8
data02
data00
0xxxxx4
data02
data03
data03
0xxxxx0
data01
data01
The size of this structure is 7 bytes in the CC78K4 and 12 bytes in the CA850.
2.5 Startup Routine (Startup Module)
This section compares the large model of the CC78K4 with the contents of the default startup routine (startup module) of the CA850 by function. Use this section for reference when customizing a startup routine. For the flow of the program (whole program), refer to the manual of each compiler.
50
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
2.5.1 Setting module name and loading include file The CC78K4 sets a module name and loads an include file. The CA850 does not have such processing. [CC78K4]
NAME @cstart
$INCLUDE (mod.inc)
[CA850] Not provided 2.5.2 Setting library switch The CC78K4 allows the startup routine to be changed to accord with the library used. corresponding to the library used are defined. The CA850 does not have such processing. [CC78K4]
BRKSW EXITSW RANDSW DIVSW LDIVSW EQU EQU EQU EQU EQU 1 1 1 1 1 1 ;brk,sbrk,calloc,free,malloc,realloc function use ;exit,atexit function use ;rand,srand ;div ;ldiv ;strtok function use function use function use function use
Therefore, symbols
STRTOKSW EQU
[CA850] Not provided 2.5.3 Defining symbols The CC78K4 has symbols that are used when the standard library is used, but the CA850 does not have such symbols. If the V850E is specified in the CA850, a symbol must be defined to specify the runtime library code of the prologue/epilogue of a function. [CC78K4]
Start/end symbols of startup routine PUBLIC _@cstart,_@cend
Symbols used when standard library is used PUBLIC PUBLIC _errno,_@BRKADR,_@MEMTOP,_@MEMBTM _@FNCTBL,_@FNCENT,_@SEED,_@DIVR,_@LDIVR,_@TOKPTR
Symbols for stack resolution EXTRN _@STBEG
Symbols of main module EXTRN _main,_hdwinit,_exit
Symbols for ROMization processing EXTRN _?R_INIT,_?R_INIS,_?R_INS1,_?DATS,_?DATS1,_?DATA
Application Note U15653EJ1V0AN
51
CHAPTER 2 C LANGUAGE
[CA850]
Start/end symbols of startup routine .globl .globl .globl __start __exit __startend
Symbols automatically generated by link editor .extern __tp_TEXT, 4 .extern __gp_DATA, 4 .extern __ep_DATA, 4 Start/end symbols of section .extern __ssbss, 4
.extern __esbss, 4 .extern __sbss, 4 .extern __ebss, 4 Symbol of main module .extern _main
Symbols used to generate runtime library code of prologue/epilogue of function (V850E only) .globl ___PROLOG_TABLE
2.5.4 Reserving area for library With the CA850, a heap area must be reserved only when the storage area management library of the standard library is used. [CC78K4]
@@DATA DSEG DS DS DS DS DS DS DS DS DS 3*32 2 4 4 8 3 2 3 48
_@FNCTBL: _@FNCENT: _@SEED: _@DIVR: _@LDIVR: _@TOKPTR: _errno: _@BRKADR: _@MEMTOP: _@MEMBTM:
[CA850] Set a heap area as follows to use the storage area management library of the standard library. description can be made in the C source, instead of the startup routine.
.sbss .comm .sdata .globl ___sizeof_sysheap ___sysheap, HEAPSIZE, 4
This
___sizeof_sysheap: .word HEAPSIZE
52
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
2.5.5 Reserving stack area The CC78K4 can reserve a stack area using the linker but an area must be explicitly reserved for the CA850. [CC78K4] No description of a stack area is available. By specifying the -S option using the linker, the maximum address area of the memory area is found and the _@STBG and _@STEND symbols are generated. [CA850]
.set .bss .lcomm __stack, STACKSIZE, 4 STACKSIZE, 0x200
Caution
Be sure to reserve a stack in 4-byte units.
2.5.6 Setting reset vector Setting a reset vector cannot be described using the #pragma directive in either the CC78K4 or the CA850. The startup routine therefore includes this description. [CC78K4]
@@VECT00 CSEG DW AT _@cstart 0H
[CA850]
.section jr __start "RESET", text
2.5.7 Setting location The location instruction of the 78K/IV Series is not provided in the V850 Family. [CC78K4]
LOCATION 0FH
[CA850] Not provided
Application Note U15653EJ1V0AN
53
CHAPTER 2 C LANGUAGE
2.5.8 Setting register bank The register bank of the 78K/IV Series is not provided in the V850 Family. [CC78K4]
SEL RB0
[CA850] Not provided 2.5.9 Setting stack pointer The CC78K4 sets a symbol generated by the linker to the stack pointer. The CA850 adds the size of the stack to the symbol at the beginning of the area explicitly reserved and sets the result to the stack pointer. [CC78K4]
MOVG SP,#_@STBEG
[CA850]
mov #__stack+STACKSIZE, sp
2.5.10 Setting general-purpose registers The CA850 accesses a program and variables by using a relative address calculated from a register value. Therefore, general-purpose registers must be set. These registers must also be set when the mask register function is used. [CC78K4] The registers do not have to be set in the case of the large model. For the medium and small models, refer to the sample below. [CA850]
mov mov add mov mov mov #__tp_TEXT, tp: #__gp_DATA, gp: tp, gp: #__ep_DATA, ep: 0xff, r20: -- Setting of text pointer --- Setting of global pointer -- Setting of element pointer -- Setting of mask register (byte) -- Setting of mask register (halfword)
0xffff, r21:
It is assumed that "use of the offset from the text pointer as the global pointer" is specified in the link directive file. Therefore, tp and gp are added and substituted for gp. The mask registers (r20 and r21) are necessary only when use of the mask registers is specified by an option.
54
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
2.5.11 Setting special registers The CA850 requires special registers to be set only when the V850E generates the runtime library code of the prologue/epilogue of a function. [CC78K4] Not provided [CA850] Set the CALLT table pointer as follows to generate the runtime library code of the prologue/epilogue of a function (V850E only).
mov ldsr #___PROLOG_TABLE, r12 r12, 20
2.5.12 Calling hardware initialization function The CC78K4 allows a hardware initialization function to be called so that customization can be made by the user, but the CA850 does not. To initialize the hardware, call a function in the same manner as in the CC78K4, or describe a function call in the startup routine. [CC78K4]
CALL !!_hdwinit
[CA850] Not provided
Application Note U15653EJ1V0AN
55
CHAPTER 2 C LANGUAGE
2.5.13 Setting default value of standard library The CC78K4 requires the default values of symbols to be set when the standard library is used, but the CA850 does not. When using the standard library in the CA850, however, ROMization processing (romp850) is necessary because variables with a default value exist. [CC78K4]
SUBW MOVW MOVW MOVW MOVW MOVG MOVG AX,AX !!_errno,AX !!_@FNCENT,AX !!_@SEED+2,AX !!_@SEED,#1 WHL,#_@MEMTOP !!_@BRKADR,WHL ;BRKADR <- #MEMTOP ;SEED <- 1 ;errno <- 0 ;FNCENT <- 0
[CA850] Not provided 2.5.14 ROMization processing With the CC78K4, ROMization processing is described in the startup module. With the CA850, the ROMization library must be called at the part of the C source that is executed first (beginning of the main function). To expand the memory, set the necessary peripheral function registers before calling the ROMization library. [CC78K4] (1/2)
; copy external variables having initial value MOVG MOVG LINIT1: SUBG BE ADDG MOV MOV BR LINIT2: ; copy external variables which doesn't have initial value MOVG MOVG MOV LDATA1: SUBG BE ADDG WHL,TDE $LDATA2 WHL,TDE TDE,#_@DATA WHL,#_?DATA A,#0 WHL,#_?R_INIT $LINIT2 WHL,#_?R_INIT A,[HL+] [DE+],A $LINIT1 TDE,#_@INIT WHL,#_@R_INIT
56
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
(2/2)
MOV BR LDATA2: ; copy sreg variables having initial value MOVG MOVG LINIS1: SUBG BE ADDG MOV MOV BR LINIS2: ; copy sreg variables which doesn't have initial value MOVG MOVG MOV LDATS1: SUBG BE ADDG MOV BR LDATS2: ; copy sreg1 variables having initial value MOVG MOVG LINIS11: SUBG BE ADDG MOV MOV BR LINIS12: ; copy sreg1 variables which doesn't have initial value MOVG MOVG MOV LDATS11: SUBG BE ADDG MOV BR LDATS12: WHL,TDE $LDATS12 WHL,TDE [DE+],A $LDATS11 TDE,#_@DATS1 WHL,#_?DATS1 A,#0 WHL,#_?R_INS1 $LINIS12 WHL,#_?R_INS1 A,[HL+] [DE+],A $LINIS11 TDE,#_@INIS1 WHL,#_@R_INS1 WHL,TDE $LDATS2 WHL,TDE [DE+],A $LDATS1 TDE,#_@DATS WHL,#_?DATS A,#0 WHL,#_?R_INIS $LINIS2 WHL,#_?R_INIS A,[HL+] [DE+],A $LINIS1 TDE,#_@INIS WHL,#_@R_INIS [DE+],A $LDATA1
Application Note U15653EJ1V0AN
57
CHAPTER 2 C LANGUAGE
[CA850] Call a copy routine (_rcopy) at the beginning of the main function.
extern main() { int ... } ret; ret = _rcopy(&_S_romp,-1); unsigned long _S_romp;
2.5.15 Initializing variable area without default value The CA850 executes initialization by using a symbol that starts/ends a section without default value. [CC78K4] Not provided [CA850]
mov mov cmp jnl .L12: st.w add cmp jl .L11: mov mov cmp jnl .L15: st.w add cmp jl .L14: r0, [r13] 4, r13 r12, r13 .L15 #__sbss, r13 #__ebss, r12 r12, r13 .L14 -- clear bss section r0, [r13] 4, r13 r12, r13 .L12 #__ssbss, r13 #__esbss, r12 r12, r13 .L11 -- clear sbss section
The above symbols are reserved words in the link editor. __ssbss: Symbol starting .sbss section __esbss: Symbol ending .sbss section __sbss: Symbol starting .bss section __ebss: Symbol ending .bss section
58
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
2.5.16 Calling main function The main function is called. [CC78K4]
CALL !!_main
[CA850]
jarl _main, lp
2.5.17 Calling exit function The CC78K4 calls the exit function but the CA850 calls the halt instruction to set the HALT mode. [CC78K4]
SUBW CALL BR AX,AX !!_exit $$
[CA850] Not provided. The HALT mode is set as is.
halt
Application Note U15653EJ1V0AN
59
CHAPTER 2 C LANGUAGE
2.5.18 Defining segment (section) The CC78K4 defines segments and labels used for ROMization processing. The CA850 defines a section without default value to initialize the section without default value. [CC78K4]
@@R_INIT CSEG _@R_INIT: @@R_INIS CSEG _@R_INIS: @@R_INS1 CSEG _@R_INS1: @@INIT _@INIT: @@DATA _@DATA: @@INIS _@INIS: @@DATS _@DATS: @@INIS1 _@INIS1: @@DATS1 _@DATS1: @@CODE @@CALF @@CNST @@CALT @@BITS @@BITS1 CSEG CSEG CSEG CSEG BSEG BSEG CALLT0 SADDR2 SADDR FIXED DSEG SADDR DSEG SADDR DSEG SADDR2 DSEG SADDR2 DSEG DSEG
[CA850]
.sbss .lcomm __sbss_dummy, 0, 0
60
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
2.6 Segment (Section) Output by Compiler
This section explains the segment output by the CC78K4 and section output by the CA850. For how to allocate the segment and section, refer to CHAPTER 4 LINK DIRECTIVES. 2.6.1 Segment Output by CC78K4 The CC78K4 outputs the following segments by default. Table 2-7. Segments Output by CC78K4
Section Name @@BASE @@VECTnn @@CODES @@CODE @@CNSTS @@CNSTM @@CNST @@CALFS @@CALF @@CALT @@RSINIT @@R_INIT @@RSINS @@R_INS @@RSINS1 @@R_INS1 @@INITM @@INIT @@DATAM @@DATA @@INIS Segment Type CSEG CSEG CSEG Usage callt function, interrupt function segment Segment for interrupt vector table Segment for ordinary function codes
CSEG
Segment for const variable
CSEG
Segment for callf function
CSEG CSEG
Segment for callt function table Segment for variable with default value
CSEG
Segment for sreg variable with default value
CSEG
Segment for sreg1 variable with default value
DSEG
Segment for temporary variable with default value Segment for variable without default value
DSEG
DSEG
Segment for temporary sreg variable with default value Segment for temporary sreg variable without default value Segment for temporary sreg1 variable with default value Segment for temporary sreg1 variable without default value Segment for boolean/bit type variable Segment for __boolean1 type variable
@@DATS
DSEG
@@INIS1
DSEG
@@DATS1
DSEG
@@BITS @@BITS1
BSEG BSEG
Application Note U15653EJ1V0AN
61
CHAPTER 2 C LANGUAGE
2.6.2 Section output by CA850 The CA850 outputs the following sections by default. Table 2-8. Sections Output by CA850
Section Name .text .pro_epi_runtime .const Type of Section text text const Section for function code Section for runtime library code of prologue/epilogue Section for const variable Section that can be accessed by ld/st instructions (two instructions) of r0 relative Section for const variable Section that can be accessed by ld/st instruction of r0 relative (addresses 0x0 to 0x8000) Section for variable with default value Section that can be accessed by ld/st instructions (two instructions) of gp relative Section for variable with default value Section that can be accessed by ld/st instruction of gp relative Section for variable with default value Section that can be accessed by ld/st instruction of ep relative (first address of internal RAM - 0x8000 to first address of internal RAM are recommended) Section for variable with default value Section that can be accessed by ld/st instruction of ep relative (internal RAM is recommended) Section for variable with default value Section that can be accessed by sld/sst instruction of ep relative (256 bytes starting from first address of internal RAM is recommended) Section for variable without default value Section that can be accessed by ld/st instructions (two instructions) of gp relative Section for variable without default value Section that can be accessed by ld/st instruction of gp relative Section for variable without default value Section that can be accessed by ld/st instruction of ep relative (first address of internal RAM - 0x8000 to first address of internal RAM are recommended) Section for variable without default value Section that can be accessed by ld/st instruction of ep relative (internal RAM is recommended) Section for variable without default value Section that can be accessed by sld/sst instruction of ep relative (256 bytes starting from first address of internal RAM is recommended) Sections including data section with default value packed for copying data with default value and section including address information of these sections Usage
.sconst
const
.data
data
.sdata
sdata
.sedata
sedata
.sidata
sidata
.tidata
tidata
.bss
bss
.sbss
sbss
.sebss
sebss
.sibss
sibss
.tibss
tibss
rompsec
text
62
Application Note U15653EJ1V0AN
CHAPTER 2 C LANGUAGE
2.7 Library and Header File
This section explains the library and header file supported by the CC78K4 and CA850. If a library that is supported by the CC78K4 but not by the CA850 is used, replace the library with one supported by the CA850. Table 2-9. Library and Header File (1/2)
Function Character, character string function CC78K4 isalnum, isalpha, iscntrl, isdigit, isgragh, islower, isprint, ispunct, isspace, isupper, isxdigit, tolower, toupper, isascii, toascii, _toupper, _tolower, tolow*, toup* setjmp, longjmp CA850 _tolower, _toupper, toascii, tolower, toupper, isalnum, isalpha, isascii, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit setjmp, longjmp
Program control function Special function I/O function
va_start, va_arg, va_end sprintf, sscanf, printf, scanf, vprintf, vsprintf, getchar, gets, putchar, puts
va_start, va_arg, va_end sprintf, sscanf, fprintf*, fscanf*, printf, scanf, vfprintf*, vprintf, vsprintf, fgetc*, fgets*, fputc*, fputs*, getc*, getchar, gets, putc*, putchar, puts, ungetc*, fread*, fwrite*, rewind*, perror* abs, labs, bsearch, div, ldiv, ecvtf*, gcvtf*, atoff*, strtodf*, atoi, atol, strtol, strtoul, rand, srand, calloc, malloc, free, realloc, qsort, itoa, ltoa, ultoa
Utility function
atoi, atol, strtol, strtoul, calloc, free, malloc, realloc, abort*, atexit*, exit*, abs, labs, div, ldiv, brk*, sbrk*, atof*, strtod*, itoa, ltoa, ultoa, rand, srand, bsearch, qsort, strbrk*, strsbrk*, stritoa*, strltoa*, strultoa* memcpy, memmove, strcpy, strncpy, strcat, strncat, memcmp, strcmp, strncmp, memchr, strchr, strrchr, strspn, strcspn, strpbrk, strstr, strtok, memset, strerror, strlen, strcoll, strxfrm
Character string/ memory function
bcmp*, bcopy*, memchr, memcmp, memcpy, memmove, memset, index*, rindex*, strcat, strchr, strcmp, strcpy, strcspn, strerror, strlen, strncat, strncmp, strncpy, strpbrk, strrchr, strspn, strstr, strtok j0f*, j1f*, jnf*, y0f*, y1f*, ynf*, erff*, erfcf*, expf, logf, log2f*, log10f, powf, sqrtf, ceilf, fabsf, floorf, fmodf, frexpf, ldexpf, modff, gammaf*, hypotf*, matherr, acoshf*, asinhf*, atanhf*, coshf, sinhf, tanhf, acosf, asinf, atanf, atan2f, cosf, sinf, tanf, cbrtf*
Mathematical function
acos*, asin*, atan*, atan2*, cos*, sin*, tan*, cosh*, sinh*, tanh*, exp*, frexp*, ldexp*, log*, log10*, modf*, pow*, sqrt*, ceil*, fabs*, floor*, fmod*, matherr, acosf, asinf, atanf, atan2f, cosf, sinf, tanf, coshf, sinhf, tanhf, expf, frexpf, ldexpf, logf, log10f, modff, powf, sqrtf, ceilf, fabsf, floorf, fmodf, __assertfail*
Application Note U15653EJ1V0AN
63
CHAPTER 2 C LANGUAGE
Table 2-9. Library and Header File (2/2)
Function Integer operation
Note
CC78K4 lsinc*, luinc*, lsdec*, ludec*, lsrev*, lurev*, lscom*, lucom*, lsnot*, lunot*, lsmul*, lumul*, csdiv*, isdiv*, lsdiv*, ludiv*, csrem*, isrem*, lsrem*, lurem*, lsadd*, luadd*, lssub*, lusub*, lslsh*, lulsh*, lsrsh*, lursh*, lscmp*, lucmp*, lsband*, luband*, lsbor*, lubor*, lsbxor*, lubxor* finc*, fdec*, frev*, fnot*, fmul*, fdiv*, fadd*, fsub*, fcmp*, fand*, for*, ftols*, ftoul*, lstof*, lutof*, btol*, None
CA850 __mul*, __mulu*, __div*, __divu*, __mod*, __modu*
Floating-point operationNote
__addf.s*, __subf.s*, __mulf.s*, __divf.s*, __cmpf.s*, __cvt.ws*, __trnc.sw*
Copying ROMization default value data Header file
_rcopy*
ctype.h, setjmp.h, stdarg.h, stdio.h, stdlib.h, string.h, error.h*, errno.h, limits.h, stddef.h, math.h, float.h, assert.h*
ctype.h, setjmp.h, stdarg.h, stdio.h, stdlib.h, string.h, errno.h, limits.h, stddef.h, math.h, float.h
Note Because these functions are those of a runtime library, they are not described in the C source program. The functions marked "*" in the above table are supported only by either the CC78K4 or CA850. For the details of the library, refer to the manual of each compiler.
64
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
This chapter explains the points to be noted when rewriting the quasi-directives and control instructions of the assembler for the RA78K4 into those for the CA850 (as850), and how to describe a program. The quasi-directives and control instructions of the RA78K4 and CA850 are as follows. Table 3-1. Quasi-Directives and Control Instructions (1/3)
No. Function 1 Segment quasi-directive RA78K4 Instruction CSEG Function Section definition quasi-directive CA850 Instruction .text .const .sconst .bss .data .sbss .sdata .sebss .sedata .sibss .sidata .tibss .tidata .tibss.byte .tidata.byte .tibss.word .tidata.word None .previous .section .vdbstrtab .vdebug .vline Location counter control quasi-directive .org .align None Symbol control quasi-directive .set .size .frame .file None
DSEG
BSEG None
ORG None 2 Symbol definition quasi-directive EQU SET None
3
Object module name declaration quasidirective
NAME
Application Note U15653EJ1V0AN
65
CHAPTER 3 ASSEMBLY LANGUAGE
Table 3-1. Quasi-Directives and Control Instructions (2/3)
No. Function 4 Memory initialization, area reservation quasi-directive DB DW DG None DS None DBIT None 5 Linkage quasi-directive PUBLIC EXTRN EXTBIT None 6 Automatic selection quasi-directive BR CALL RSS None Program linkage quasi-directive RA78K4 Instruction Function Area reservation quasi-directive .byte .hword None .word .lcomm .space None .float .globl .extern None .comm CA850 Instruction
7
General-purpose register selection quasi-directive Macro quasi-directive
None
8
MACRO LOCAL ENDM EXITM None REPT IRP
Macro quasi-directive
.macro .local .endm
Skip quasi-directive
.exitm .exitma
Repeat assemble quasi-directive
.repeat .irepeat
9 10
Assemble end quasi-directive Assemble target model specification control instruction Debug information output control instruction
END $PROCESSOR
None Assembler control quasi-directive .option cpu
11
$DEBUG/ $NODEBUG $DEBUGA/ $NODEBUGA $XREF/$NOXREF $SYMLIST/ $NOSYMLIST $INCLUDE None
None
12
Cross-reference list output specification control instruction
None
13
Include control instruction
File input control quasi-directive
.include .binclude
66
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
Table 3-1. Quasi-Directives and Control Instructions (3/3)
No. Function 14 Assemble list control instruction RA78K4 Instruction $EJECT $TITLE $SUBTITLE $LIST/$NOLIST $GEN/$NOGEN $COND/$NOCOND $FORMFEED/ $NOFORMFEED $WIDTH $LENGTH $TAB $SET $RESET $IF None $_IF None $ELSEIF $_ELSEIF None $ELSE $ENDIF 16 SFR area change control instruction $CHGSFR $CHGSFRA None None Function CA850 Instruction
15
Conditional assembly control instruction
None
Conditional assembly quasi-directive
.ifdef .ifndef .if .ifn .elseif
.elseifn .else .endif
Application Note U15653EJ1V0AN
67
CHAPTER 3 ASSEMBLY LANGUAGE
3.1 Segment Quasi-Directive (Section Definition Quasi-Directive)
This section explains quasi-directives related to segments (sections). 3.1.1 CSEG, .text, .const, .sconst These are quasi-directives that define the segments (sections) to be allocated to ROM. The RA78K4 uses the CSEG quasi-directive to define the segment of a program and a variable that is only referenced. The CA850 uses the .text quasi-directive to define a program section, and the .sconst or .const quasidirective to define the section of a variable that is only referenced. [RA78K4] CSEG: Indicates the start of a code segment. The description format is as follows. [segment name] CSEG [relocation attribute]
CSEG MOV CSEG DATAC0: DB DATAC1: DB CSEG DATAC2: DW 5678H UNIT A,B BASE 12H 34H
68
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
[CA850] .text: Allocates generated codes to the .text section. The description format is as follows. .text .const: Allocates generated codes to the .const section. The .const section is a section for constant data (read-only) and is located in memory that is referenced by two instructions, using r0 and 32-bit displacement. The description format is as follows. .const .sconst: Allocates generated codes to the .sconst section. The .sconst section is a section for constant data (read-only) and is located in a memory range (up to 32 KB in the plus direction from r0) that is referenced by one instruction, using r0 and 16-bit displacement. The description format is as follows. .sconst
.text .align 4 mov .const DATAC0: .byte DATAC1: .byte .sconst DATAC2: .hword 0x5678 0x34 0x12 r10,r11
Application Note U15653EJ1V0AN
69
CHAPTER 3 ASSEMBLY LANGUAGE
3.1.2 DSEG, .bss, .data, .sbss, .sdata, .sebss, .sedata, .sibss, .sidata, .tibss, .tidata, .tibss.byte, .tidata.byte, .tibss.word, .tidata.word These quasi-directives define segments (sections) to be allocated to RAM. The RA78K4 uses the DESG quasi-directive to define the segments of variables other than bit variables. In the CA850, bit variables do not have sections, and the section of a variable is defined by using the .bss and .data quasidirectives, which are not dependent on the address to be located, or the .sbss and .sdata quasi-directives, which are dependent on the GP register value. In addition, defining to the external RAM immediately before the internal RAM is performed by the .sebss or .sedata quasi-directive. Defining to the internal RAM is performed by the .sibss, .sidata, .tibss, .tidata, tibss.byte, .tidata.byte, tibss.word, or .tidata.word quasi-directive. [RA78K4] DSEG: Indicates the start of a data segment. The description format is as follows. [segment name] DSEG [relocation attribute]
DSEG DATAD0: DS DSEG DATAD2: DS DSEG DATAD4: DS DSEG DATAD6: DS DSEG DATAD8: DS DSEG DATAD10: DS DSEG DATAD12: DS 2 SADDR 2 SADDR2 2 SADDR2 1 SADDRP2 2 UNIT 1 UNITP 2
[CA850] .bss: Allocates generated codes to the .bss section. The .bss section does not have a default value and is located in a memory range that is referenced by two instructions, using gp and 32-bit displacement. The description format is as follows. .bss .data: Allocates generated codes to the .data section. The .data section has a default value and is located in a memory range that is referenced by two instructions, using gp and 32-bit displacement. The description format is as follows. .data
70
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
.sbss:
Allocates generated codes to the .sbss section. The .sbss section does not have a default value and is located in a memory range (up to 64 KB including the .sdata section) that is referenced by one instruction, using gp and 16-bit displacement. The description format is as follows. .sbss
.sdata:
Allocates generated codes to the .sdata section. The .sdata section has a default value and is located in a memory range (up to 64 KB including .sbss section) that is referenced by one instruction, using gp and 16-bit displacement. The description format is as follows. .sdata
.sebss:
Allocates generated codes to the .sebss section. The .sebss section does not have a default value and is located at the higher addresses equaling the size of the .sedata section in the memory range (32 KB in the minus direction from ep) that is referenced by one instruction, using ep and 16-bit displacement. The description format is as follows.
.sebss .sedata: Allocates generated codes to the .sedata section. The .sedata section has a default value and is located at the lower addresses equaling the size of the .sebss section in the memory range (32 KB in the minus direction from ep) that is referenced by one instruction, using ep and 16-bit displacement. The description format is as follows. .sedata .sibss: Allocates generated codes to the .sibss section. The .sibss section does not have a default value and is located in the memory range (32 KB in the plus direction from ep, i.e., internal RAM) that is referenced by one instruction, using ep and 16-bit displacement. The description format is as follows. .sibss .sidata: Allocates generated codes to the .sidata section. The .sidata section has a default value and is located in the memory range (32 KB in the plus direction from ep, i.e., internal RAM) that is referenced by one instruction, using ep and 16-bit displacement. The description format is as follows. .sidata
Application Note U15653EJ1V0AN
71
CHAPTER 3 ASSEMBLY LANGUAGE
.tibss:
Allocates generated codes to the .tibss section. The .tibss section is a section of data without a default value and is assumed to be accessed by ep relative, using the sld/sst instruction is added. The description format is as follows. .tibss
Note
. If both the .tibss.byte and .tibss.word sections are used,
.tibss is located at the address indicated by ep to which the sum of the size of the both the sections
.tidata:
Allocates generated codes to the .tidata section. The .tidata section is a section of data with a default value and is assumed to be accessed by ep relative, using the sld/sst instruction added. The description format is as follows. .tidata
Note
. If both the .tidata.byte and .tidata.word sections are used,
.tidata is located at the address indicated by ep to which the sum of the size of both the sections is
.tibss.byte:
Allocates generated codes to the .tibss.byte section. The .tibss.byte section is a section of data without a default value and is assumed to be accessed by ep relative, using the sld/sst instruction accessed by the sld/sst instruction the address indicated by ep. The description format is as follows.
Note Note
. To effectively use the area that can be
, the section is divided into a .tibss.byte section and a
.tibss.word section, depending on the size of the data, and the .tibss.byte section is allocated at
.tibss.byte .tidata.byte: Allocates generated codes to the .tidata.byte section. The .tidata.byte section is a section of data with a default value and is assumed to be accessed by ep relative, using the sld/sst instruction by the sld/sst instruction address indicated by ep. The description format is as follows. .tidata.byte Note The sld/sst instruction is a 2-byte instruction that can access an area of up to 128 bytes if the data to be accessed is byte data, or an area of up to 256 bytes if the data to be accessed is a halfword or larger data.
Note Note
. To effectively use the area that can be accessed
, the section is divided into a .tidata.byte section and a .tidata.word
section, depending on the size of the data, and the .tidata.byte section is allocated at the
72
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
.tibss.word:
Allocates generated codes to the .tibss.word section. The .tibss.word section is a section of data without a default value and is assumed to be accessed by ep relative, using the sld/sst instruction accessed by the sld/sst instruction
Note Note
. To effectively use the area that can be
, the section is divided into a .tibss.byte section and a
.tibss.word section, depending on the size of the data, and is located at the address indicated by ep to which the size of the .tibss.byte section is added. The description format is as follows. .tibss.word .tidata.word: Allocates generated codes to the .tidata.word section. The .tidata.word section is a section of data with a default value and is assumed to be accessed by ep relative, using the sld/sst instruction by the sld/sst instruction
Note Note
. To effectively use the area that can be accessed
, the section is divided into a .tidata.byte section and a .tidata.word
section, depending on the size of the data, and is located at the address indicated by ep to which the size of the .tidata.byte section is added. The description format is as follows. .tidata.word Note The sld/sst instruction is a 2-byte instruction that can access an area of up to 128 bytes if the data to be accessed is byte data, or an area of up to 256 bytes if the data to be accessed is a halfword or larger data.
Application Note U15653EJ1V0AN
73
CHAPTER 3 ASSEMBLY LANGUAGE

.bss .lcomm .data DATAD1: .byte .sbss .lcomm .sdata DATAD3: .hword .sebss .lcomm .sedata DATAD5: .hword .sibss .lcomm .sidata DATAD7: .hword .tibss .lcomm .tidata DATAD9: .hword 0x4321 DATAD8,0x2,2 0xfedc DATAD6,0x2,2 0xabcd DATAD4,0x2,2 0xffff DATAD2,0x2,2 0xff DATAD0,0x1,1
.tibss.byte .lcomm DATAD10,0x1,1
.tidata.byte DATAD11: .byte 0x21
.tibss.word .lcomm DATAD12,0x2,2
.tidata.word DATAD13: .hword 0x5678
74
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
3.1.3 BSEG This quasi-directive defines a segment (section) to be allocated to RAM. The RA78K4 uses the BSEG quasi-directive to define the segment of a bit variable, but in the CA850, a bit variable does not have a section. [RA78K4] BSEG: Indicates the start of a bit segment. The description format is as follows. [segment name] BSEG [relocation attribute]
BSEG DATAB0 DATAB1 DBIT DBIT CSEG SET1 CLR1 DATAB0 DATAB1
[CA850] Not provided. Reserve an area in a size such as bytes, and access the area by specifying a bit position using the set1, clr1, or tst1 instruction.
.bss .lcomm .text set1 clr1 0,$DATAB[gp] 1,$DATAB[gp] DATAB,0x1,1
Application Note U15653EJ1V0AN
75
CHAPTER 3 ASSEMBLY LANGUAGE
3.1.4 .previous, .section These quasi-directives define a segment (section). The RA78K4 can specify a segment name using the CSEG, DSEG, or BSEG quasi-directive. The CA850 specifies a section name using the .section quasi-directive. The CA850 can specify the section specified by the previous section quasi-directive, by using .previous. [RA78K4] A quasi-directive equivalent to .previous is not available. A segment name can be specified by CSEG, DSEG, or BSEG.
SEG1 CSEG MOV SEG2 SEGL0: DSEG DS 2 A,B
[CA850] .previous: Specifies (again) the section definition quasi-directive preceding the section definition quasi-directive that specified the current section quasi-directive. The description format is as follows. .previous .section: Allocates a code generated for the program as a section name specified by the first operand to the type of the section specified by the second operand. The description format is as follows. .section "section name" [,type of section]
.section "SEG1",text mov r10,r11
.section "SEG2",bss .lcomm SEGL0,2,2
76
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
3.1.5 ORG, .org These quasi-directives define a segment (section). The RA78K4 uses the ORG quasi-directive to specify the absolute address of a segment. The CA850 cannot specify the absolute address of a section but only increments the location counter that indicates the current section. To specify an absolute value, specify the location of the section using the link directive file. [RA78K4] ORG: Sets the value of an expression specified by the operand to the location counter. After this quasi-directive, the segment is located starting from the address belonging to an absolute segment and specified by the operand. The description format is as follows. [segment name] ORG absolute expression
"MOV A,C" is allocated to the segment that is located at address 0x100. CSEG MOV ORG MOV A,B 0100H A,C
[CA850] .org: Increments the value of the location counter for the current section specified by the previously specified section definition quasi-directive to the value specified by the operand. This quasi-directive does not specify the absolute address of a section. If a hole is generated as a result of incrementing the value of the location counter, the hole is filled with 0. The description format is as follows. .org value
"mov r12,r11" is allocated to the address indicated by the location counter of the .text section incremented by 0x100.
.text mov .org mov r10,r11 0x100 r12,r11
Application Note U15653EJ1V0AN
77
CHAPTER 3 ASSEMBLY LANGUAGE
3.1.6 .align This quasi-directive specifies the alignment condition of a segment (section). It is not provided in the RA78K4. The CA850 can specify the alignment condition of a section using the .align quasi-directive. [RA78K4] Not provided [CA850] .align: Aligns the value of the location counter for the current section specified by the previously specified section definition quasi-directive under the alignment condition specified by the first operand. If a hole is generated as a result of aligning the location counter value, it is filled with the filling value specified by the second operand or the default value 0. The description format is as follows. .align alignment condition [,filling value]
.text .align 4 .globl func: jmp [lp] func
3.2 Symbol Definition Quasi-Directives (Symbol Control Quasi-Directives)
This section explains the quasi-directives related to symbols.
78
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
3.2.1 EQU The RA78K4 has the EQU and SET quasi-directives, which define a name. The CA850 supports only the .set quasi-directive, which sets a value to a name. [RA78K4] EQU: Defines a name having the value of the expression specified by the operand. The description format is as follows. name EQU expression DATAE EQU 0FE00H
[CA850] Not provided. Use the .set quasi-directive to specify a numeric value. 3.2.2 SET, .set The RA78K4 uses the SET quasi-directive to define a name, but the CA850 uses the .set quasi-directive to set a value to a name. [RA78K4] SET: Defines a name having the value of the expression specified by the operand. This quasi-directive can be re-defined in the same module. The description format is as follows. name SET absolute expression DATAS SET 100
[CA850] .set: Defines a symbol having the symbol name specified by the first operand and the value (integer value) specified by the second operand. The description format is as follows. .set symbol name, value .set DATAE,0xfe00
Application Note U15653EJ1V0AN
79
CHAPTER 3 ASSEMBLY LANGUAGE
3.2.3 .size, .frame, .file The CA850 has the .size quasi-directive, which gives a size to a label, the .frame quasi-directive for debugging at the C language level, and the .file quasi-directive, which defines a file name. [RA78K4] Not provided [CA850] .size: Specifies the size specified by the second operand as the size of the data indicated by the label specified by the first operand. The description format is as follows. .size label name, size .frame: Generates a symbol table entry having the size specified by the second operand and the type FUNC when an object file is generated and when a symbol table entry for the label specified by the first operand is generated. This quasi-directive is used for debugging at the C language level. The description format is as follows. .frame label name, size .file: Generates a symbol table entry having the file name specified by the operand and type FUNC when an object file is generated. .file "file name"
.file "main.s"
3.3 Object Module Name Declaration Quasi-Directives
This section explains the quasi-directives related to object module names.
80
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
3.3.1 NAME The RA78K4 has the NAME quasi-directive, which defines the name of an object module, but the CA850 does not have such a quasi-directive. [RA78K4] NAME: Assigns the object module name described as the operand to the object module output by the assembler. The description format is as follows. NAME object module name [CA850] Not provided
3.4 Memory Initialization and Area Reservation Quasi-Directives (Area Reservation QuasiDirectives)
This section explains the quasi-directives that initialize the memory or reserve a memory area. 3.4.1 DB, .byte The RA78K4 uses the DB quasi-directive and the CA850 uses the .byte quasi-directive to reserve a 1-byte area of memory [RA78K4] DB: Initializes a byte area (1 byte). If the size is specified by the operand, an area of the specified size is initialized by 0. If the default value is specified by the operand, the area is initialized by the specified default value. The following two description formats are available. DB (size) DB default value [, ...]
CSEG DBDATA0: DB DBDATA1: DB (1) 0AAH,0BBH
Application Note U15653EJ1V0AN
81
CHAPTER 3 ASSEMBLY LANGUAGE
[CA850] .byte: The first format of this quasi-directive reserves an area of 1 byte for each operand, and stores the lower byte of the specified value in the reserved area. The second format reserves an area of the specified bit width, and stores the specified value in that area. The following two description formats are available. .byte value [, value...] .byte bit width: value [, bit width: value ...]
.sdata DBDATA0: .space DBDATA1: .byte 0xaa,0xbb 1
3.4.2 DW, .hword The RA78K4 uses the DW quasi-directive and the CA850 uses the .hword quasi-directive to reserve a 2-byte area of memory. [RA78K4] DW: Initializes a word area (2 bytes). If the size is specified by the operand, an area of the specified size x 2 bytes is initialized by 0. If the default value is specified by the operand, the area is initialized by the specified default value. The following two description formats are available. DW (size) DW default value [, ...]
CSEG DWDATA0: DW DWDATA1: DW (1) 0CCCCH,0DDDDH
82
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
[CA850] .hword: The first format of this quasi-directive reserves an area of 1 halfword for each operand and stores the lower halfword of the specified value in the reserved area. The second format reserves an area of the specified bit width and stores the specified value in that area. The following two description formats are available. .hword value [, value ...] .hword bit width: value [, bit width: value ...]
.sdata DWDATA0: .space DWDATA1: .hword 0xcccc,0xdddd 2
3.4.3 DG The RA78K4 uses the DG quasi-directive to reserve a 3-byte area of memory. The CA850 does not have a quasidirective that reserves a 3-byte area and supports only the .word quasi-directive that reserves a 4-byte area. For details of the .word quasi-directive, refer to 3.4.4 .word. [RA78K4] DG: Initializes a 3-byte area. If the size is specified by the operand, an area of the specified size x 3 bytes is initialized by 0. If the default value is specified by the operand, the area is initialized by the specified default value. The following two description formats are available. DG (size) DG default value [, ...]
CSEG DGDATA0: DG DGDATA1: DG (1) 0123456H,0789ABCH
[CA850] Not provided
Application Note U15653EJ1V0AN
83
CHAPTER 3 ASSEMBLY LANGUAGE
3.4.4 .word The CA850 uses the .word quasi-directive to reserve a 4-byte area of memory. [RA78K4] Not provided [CA850] .word: The first format of this quasi-directive reserves an area of 1 word for each operand and stores the lower word of the specified area in that area. The second format reserves an area of the specified bit width and stores the specified value in that area. The following two description formats are available. .word value [, value ...] .word bit width: value [, bit width: value ...]
.sdata DGDATA0: .space DGDATA1: .word 0x123456,0x789abc 4
3.4.5 .space The CA850 uses the .space quasi-directive to reserve memory of specified size and fill that area with the specified value. Filling the area with 0 is equivalent to specifying the size for DB, DW, or DG with the RA78K4. [RA78K4] Filling the specified area with 0 is equivalent to specifying the size for DB, DW, or DG. For the description format and example, refer to the explanation of each quasi-directive. [CA850] .space: Reserves an area of the size specified by the first operand and fills the area with the filling value specified by the second operand (the default value is 0). The description format is as follows. Refer to the explanation of DB, DW, and DG for an example. .space size [, filling value]
.sdata SPDATA: .space 4
84
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
3.4.6 .shword The CA850 uses the .shword quasi-directive to reserve a 2-byte area and store a specified value shifted 1 bit to the right in that area. This instruction is supported only by the V850E and is used when the switch instruction is used. [RA78K4] Not provided [CA850] (V850E only) .shword: The first format of this quasi-directive reserves an area of 1 halfword for each operand and stores the specified value shifted 1 bit to the right in that area. The second format reserves an area of the specified bit width and stores the specified value shifted 1 bit to the right in that area. The following two description formats are available. .shword value [, value ...] .shword bit width: value [, bit width; value ...] The value 0x2222, which is obtained as a result of shifting 0x4444 1 bit to the right, is stored in the area.
.sdata SHDATA0: .shword 0x4444
3.4.7 DS, .lcomm The RA78K4 uses the DS quasi-directive and the CA850 uses the .lcomm quasi-directive to reserve memory of the specified number of bytes. [RA78K4] DS: Reserves a memory area of the number of bytes specified by the operand. The description format is as follows. DS absolute expression
DSEG DSDATA0: DS DSDATA1: DS 1 2
Application Note U15653EJ1V0AN
85
CHAPTER 3 ASSEMBLY LANGUAGE
[CA850] .lcomm: Aligns the location counter for the current section under the alignment condition specified by the third operand, reserves an area of the size specified by the second operand, and defines a local label having the label name specified by the first operand for the start address of that area. The description format is as follows. .lcomm label name, size, alignment condition
.sbss .lcomm .lcomm DSDATA0,1,1 DSDATA1,2,2
3.4.8 DBIT The RA78K4 defines reserving a 1-bit memory area using the DBIT quasi-directive. The CA850 does not have a quasi-directive that reserves a 1-bit memory area. Reserve an area in a size such as bytes, and access it by specifying a bit position using the set1, clr1, or tst1 instruction. [RA78K4] DBIT: Reserves a 1-bit memory area in a bit segment. The description format is as follows. name DBIT
BSEG DATAB0 DATAB1 DBIT DBIT
CSEG SET1 CLR1 DATAB0 DATAB1
[CA850] Not provided. Reserve an area in a size such as bytes, and access it by specifying a bit position using the set1, clr1, or tst1 instruction.
.bss .lcomm DATAB,0x1,1
.text set1 clr1 0,$DATAB[gp] 1,$DATAB[gp]
Application Note U15653EJ1V0AN
86
CHAPTER 3 ASSEMBLY LANGUAGE
3.4.9 .float, .str The CA850 uses the .float quasi-directive to reserve a floating-point value and the .str quasi-directive to reserve a character string. The RA78K4 does not have quasi-directives equivalent to these. [RA78K4] Not provided [CA850] .float: Reserves an area of 1 word for each operand and stores a floating-point value in that area. The description format is as follows. .float value [, value ...] .str: Reserves an area of the specified character string for each operand and stores the specified character string in that area. The description format is as follows. .str character string constant [, character string constant ...]
.sdata FDATA: .float STRDATA: .str "NEC" 1.234
3.5 Linkage Quasi-Directives (Program Linkage Quasi-Directives)
This section explains the quasi-directives related to linkage. 3.5.1 PUBLIC, .globl The RA78K4 uses the PUBLIC quasi-directive and the CA850 uses the .globl quasi-directive to define that a symbol is a global symbol. [RA78K4] PUBLIC: Declares that the symbol described as the operand can be referenced by other modules. The description format is as follows. PUBLIC symbol name [, symbol name ...]
PUBLIC PUBSYM
Application Note U15653EJ1V0AN
87
CHAPTER 3 ASSEMBLY LANGUAGE
[CA850] .globl: Declares an external label of the same name as the label name specified by the first operand. If the second operand is specified, the specified value is specified as the size of the data indicated by that label. The description format is as follows. .globl label name [, size]
.globl PUBSYM
3.5.2 EXTRN, .extern The RA78K4 uses the EXTRN quasi-directive and the CA850 uses the .extern quasi-directive to declare that a symbol is a global symbol defined by an other module. [RA78K4] EXTRN: Declares the symbol of an other module (except a bit symbol) referenced by this module. The following three description formats are available. EXTRN symbol name [, symbol name ...] EXTRN SADDR2 (symbol name [, symbol name ...]) EXTRN BASE (symbol name [, symbol name ...])
EXTRN EXTRN EXSYM0 SADDR2(EXSYM1)
[CA850] .extern: Declares a label name the same as the label name specified by the first operand as an external label name. If the second operand is specified, the specified value is specified as the size of the data indicated by that label. The description format is as follows. .extern label name [, size]
.extern .extern EXSYM0 EXSYM1
88
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
3.5.3 EXTBIT The RA78K4 uses the EXTBIT quasi-directive to declare that a symbol is a global bit symbol defined by an other module. The CA850 does not have an equivalent quasi-directive because it does not have bit symbols. [RA78K4] EXTBIT: Declares the bit symbol of an other module referenced by this module. The following two description formats are available. EXTBIT symbol name [, symbol name ...] EXTBIT SADDR2 (symbol name [, symbol name ...])
EXTBIT EXTBIT EXBSYM0 SADDR2(EXBSYM1)
[CA850] Not provided. Specify and reference an area of 1 byte or more using the .extern quasi-directive. 3.5.4 .comm The CA850 uses the .comm quasi-directive to define an undefined external label. The RA78K4 does not have a quasi-directive equivalent to .comm. [RA78K4] Not provided [CA850] .comm: Declares an undefined external label having the label name specified by the first operand, size specified by the second operand, and alignment condition specified by the third operand. The description format is as follows. .comm label name, size, alignment condition
.comm EXSYM1,1,1
Application Note U15653EJ1V0AN
89
CHAPTER 3 ASSEMBLY LANGUAGE
3.6 Automatic Selection Quasi-Directives
This section explains the automatic selection quasi-directives. 3.6.1 BR, CALL In the RA78K4, the assembler can automatically select a branch instruction or a subroutine call instruction. The CA850 does not have quasi-directives equivalent to BR and CALL. [RA78K4] BR: The assembler automatically selects a BR branch instruction of 2 to 4 bytes according to the value of the expression specified by the operand and outputs a corresponding object code. The description format is as follows. BR expression CALL: The assembler automatically selects a CALL instruction of 3 or 4 bytes according to the value of the expression specified by the operand and outputs a corresponding object code. The description format is as follows. CALL expression
BR CALL JLABEL0 JLABEL1
[CA850] Not provided. Describe a branch instruction by using the jr or jarl instruction. However, use the jmp instruction for a branch that exceeds the displacement.
90
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
3.7 General-Purpose Register Selection Quasi-Directive
This section explains the general-purpose register selection quasi-directive. 3.7.1 RSS The CA850 does not have a quasi-directive equivalent to the RSS quasi-directive. [RA78K4] RSS: Generates an object code based on the value of the register set selection flag specified by the operand and by replacing the general-purpose register of the function name described in the program with a general-purpose register of an absolute name. The description format is as follows. RSS 0 or 1
RSS 0
[CA850] Not provided. The device does not have this function.
Application Note U15653EJ1V0AN
91
CHAPTER 3 ASSEMBLY LANGUAGE
3.8 Macro Quasi-Directives (Macro, Skip, Repeat Assemble Quasi-Directives)
This section explains the macro quasi-directives. 3.8.1 MACRO, .macro The RA78K4 uses the MACRO quasi-directive and the CA850 uses the .macro quasi-directive to define a macro. [RA78K4] MACRO: Defines a macro by giving a macro name to a series of statements described between the MACRO and ENDM quasi-directives. The description format is as follows. macro name MACRO [formal parameter [[, ...]]
ADDMAC MACRO MOV ADD ENDM A,#PARA1 A,#PARA2 PARA1,PARA2
[CA850] .macro: Defines statements enclosed between the .macro and .endm quasi-directives as the macro body of the name specified by the first operand. The description format is as follows. .macro macro name [formal parameter,] ...
.macro mov add .endm ADDMAC PARA1,PARA2
PARA1,r10 PARA2,r10
92
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
3.8.2 LOCAL, .local The RA78K4 uses the LOCAL quasi-directive and the CA850 uses the .local quasi-directive to declare a local symbol in a macro. [RA78K4] LOCAL: Declares that a symbol name specified in the operand field is a local symbol that is valid only in the macro body. The description format is as follows. LOCAL symbol name [, ...]
JMAC MACRO LOCAL LAB: BR ENDM $LAB LAB
[CA850] .local: Declares the specified character string as a local symbol that can be replaced by a specific identifier. The description format is as follows. .local Local symbol [, local symbol] ...
.macro .local LAB: jr .endm LAB JMAC LAB
Application Note U15653EJ1V0AN
93
CHAPTER 3 ASSEMBLY LANGUAGE
3.8.3 REPT, .repeat The RA78K4 uses the REPT quasi-directive and the CA850 uses the .repeat quasi-directive to repeatedly expand a macro. [RA78K4] REPT: The assembler repeatedly expands the series of statements described between the REPT and ENDM quasi-directives the number of times specified by the value of the expression specified by the operand. The description format is as follows. REPT absolute expression
REPT NOP ENDM 3
[CA850] .repeat: Repeatedly assembles the series of statements enclosed by the .repeat and .endm quasi-directives the number of times assigned by the absolute value expression specified by the first operand. The description format is as follows. .repeat absolute value expression
.repeat nop .endm 3
94
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
3.8.4 IRP, .irepeat The RA78K4 uses the IRP quasi-directive and the CA850 uses the .irepeat quasi-directive to expand a macro repeatedly with a formal parameter. [RA78K4] IRP: Repeatedly expands the series of statements between the IRP and ENDM quasi-directives as many times as the number of actual parameters, replacing the formal parameters with the actual parameters specified by the first operand. The description format is as follows. IRP formal parameter,
IRP ADD MOV INCW ENDM PARA,<0AH,0BH,0CH> A,#PARA [HL],A HL
[CA850] .irepeat: Repeatedly assembles statements enclosed by the .irepeat and .endm quasi-directives, replacing the formal parameters specified by the first operand with the actual parameters specified by the second operand. The description format is as follows. .irepeat formal parameter actual parameter [, actual parameter] ...
.irepeat PARA add st.b add .endm PARA,r10 r10,[r11] 1,r11 0xa,0xb,0xc
Application Note U15653EJ1V0AN
95
CHAPTER 3 ASSEMBLY LANGUAGE
3.8.5 EXITM, .exitm, .exitma The RA78K4 uses the EXITM quasi-directive to forcibly stop expansion of a macro body or repeated expansion of a macro. The CA850 does not have a quasi-directive that forcibly stops expansion of a macro body. To forcibly stop repeated expansion of a macro, however, the .exitm or.exitma quasi-directive is used. [RA78K4] EXITM: Forcibly returns the nesting level of macro body expansion, REPT quasi-directive, or IRP quasidirective to the nesting level when the macro body expansion, REPT quasi-directive, or IRP quasidirective was executed. The description format is as follows. EXITM
REPT 10
$_IF(SW1 < 5) DB EXITM $ELSE DB $ENDIF $_IF(SW1 > 10) DB $ELSE DB $ENDIF ENDM 05H 0AH 00H 0FH
96
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
[CA850] .exitm: Skips repeated assembly of the innermost quasi-directive of those that enclose this quasi-directive. The description format is as follows. .exitm .exitma: Skips repeated assembly of the outermost quasi-directive of those that encloses this quasi-directive. The description format is as follows. .extima
.sdata .repeat 10 .if SW1 < 5 .byte .exitm .else .byte .endif .if SW1 > 10 .byte .else .byte .endif .endm 0x05 0xa 0x0 0xf
.repeat 5 .if SW2 > 5 .byte .if 0xf SW2 < 10 .byte .exitma .else .byte .endif .else .byte .endif .endm 0x0 0x05 0xa
Application Note U15653EJ1V0AN
97
CHAPTER 3 ASSEMBLY LANGUAGE
3.8.6 ENDM, .endm The RA78K4 uses the ENDM quasi-directive and the CA850 uses the .endm quasi-directive to define the end of a macro. [RA78K4] ENDM: Informs the assembler of the end of a series of statements defined as a macro function. The description format is as follows. ENDM
ADDMAC MACRO MOV ADD ENDM A,#PARA1 A,#PARA2 PARA1,PARA2
[CA850] .endm: Indicates the end of a repeated zone or a macro body. The description format is as follows. .endm
.macro mov add .endm ADDMAC PARA1,PARA2
PARA1,r10 PARA2,r10
3.9 Assemble End Quasi-Directive
This section explains the assemble end quasi-directive. 3.9.1 END The RA78K4 uses the END quasi-directive to declare the end of an assembler source module. The CA850 does not have such a quasi-directive because it is not necessary to declare the end of the assembler module using a quasi-directive. [RA78K4] END: Declares the end of the source module to the assembler. The description format is as follows. END
98
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
[CA850] Not provided. It is not necessary to describe a keyword indicating the end at the end of the source file.
3.10 Assembler Target Model Specification Control Instructions (Assembler Control Quasi-Directives)
This section explains the assembler target model specification control instructions (assembler control quasidirectives). 3.10.1 $PROCESSOR, .option The RA78K4 uses the $PROCESSOR control instruction and the CA850 uses the .option quasi-directive to describe the model to be assembled in the assembler source file. However, the .option quasi-directive has functions other than to specify the target model. For details, refer to CA850 Assembly Language (U15027E). [RA78K4] $PROCESSOR: Specifies the model to be assembled. The description format is as follows. $PROCESSOR (model name) $PC (model name)
$PROCESSOR (4038)
[CA850] .option: Controls the assembler in accordance with the option specified as the operand. Specify cpu to specify the model to be assembled. The description format is as follows. .option cpu model name
.option cpu 3003
Application Note U15653EJ1V0AN
99
CHAPTER 3 ASSEMBLY LANGUAGE
3.11 Debug Information Output Control Instructions
This section explains the debug information output control instructions. 3.11.1 $DEBUG, $NODEBUG, $DEBUGA, $NODEBUGA The RA78K4 can specify control of debug information on the source file by using a control instruction. The CA850 does not have a quasi-directive corresponding to such a control instruction. Specify debug information using an option. [RA78K4] $DEBUG: $NODEBUG: $DEBUGA: $NODEBUGA: [CA850] Not provided. To output debug information, specify it using an option. Outputs local symbol information. Does not output local symbol information. Outputs assembler source debug information. Does not output assembler source debug information.
3.12 Cross-Reference List Output Specification Control Instructions
This section explains the cross-reference list output specification control instructions. 3.12.1 $XREF, $NOXREF, $SYMLIST, $NOSYMLIST The RA78K4 has control instructions that control output of a cross-reference list and a symbol list. The CA850 cannot output a cross-reference list. Reference cross-reference information by using cxref. Also, the CA850 cannot output a symbol list. Reference symbol information by using dump850 or rammap. [RA78K4] $XREF: $NOXREF: $SYMLIST: $NOSYMLIST: [CA850] Not provided. Reference a cross-reference list by using a cross-reference tool (cxref). Reference symbols by using a dump tool (dump850) or memory visualization tool (rammap). Outputs a cross-reference list. Does not output a cross-reference list. Outputs a symbol list. Does not output a symbol list.
100
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
3.13 Include Control Instructions (File Input Control Quasi-Directives)
This section explains the include control instructions (file input control quasi-directives). 3.13.1 $INCLUDE, .include The RA78K4 uses the $INCLUDE control instruction and the CA850 uses the .include quasi-directive to specify an include file. [RA78K4] $INCLUDE: Inserts, expands, and assembles the contents of a specified file. The description format is as follows. $INCLUDE (file name) $IC (file name)
$INCLUDE(MAIN.H)
[CA850] .include: Treats the contents of the file specified by the operand as if it were placed at the position of this quasi-directive. The description format is as follows. .include "file name"
.include "main.h"
3.13.2 .binclude The CA850 can include a binary file. [RA78K4] Not provided [CA850] .binclude: Places the contents of the file specified by the operand at the position of this quasi-directive as binary data unchanged. The description format is as follows. .binclude "file name"
.binclude "sub.o"
Application Note U15653EJ1V0AN
101
CHAPTER 3 ASSEMBLY LANGUAGE
3.14 Assemble List Control Instructions
This section explains the assemble list control instructions. 3.14.1 $EJECT, $TITLE, $SUBTITLE, $LIST, $NOLIST, $GEN, $NOGEN, $COND, $NOCOND, $FORMFEED, $NOFORMFEED, $WIDTH, $LENGTH, $TAB The RA78K4 has control instructions that control the number of characters on one line and the number of lines on one page of an assemble list. The CA850 does not have an instruction that controls the assemble list. [RA78K4] $EJECT: $TITLE: $SUBTITLE: $LIST: $NOLIST: $GEN: $NOGEN: $COND: $NOCOND: $FORMFEED: $NOFORMFEED: $WIDTH: $LENGTH: $TAB: [CA850] Not provided. The assemble list file cannot be manipulated. Instructs the assembler to execute a page break of the assemble list. Specifies a character string to be printed in the title field of the header of each page of the assemble list. Specifies a character string to be printed as the subtitle on each page header of the assemble list. Informs the assembler of the output start position of the assemble list. Informs the assembler of the output stop position of the assemble list. Instructs to output macro expansion to the assemble list. Instructs not to output macro expansion to the assemble list. Instructs to output the conditions not satisfied in conditional assembly to the assemble list. Instructs not to output the conditions not satisfied in conditional assembly to the assemble list. Instructs to output form feed at the end of the list file. Instructs not to output form feed at the end of the list file. Indicates the maximum number of characters on one line of a list file. Indicates the number of lines on one page of a list file. Indicates the number of characters to be expanded of the tab of a list file.
102
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
3.15 Conditional Assembly Control Instructions (Conditional Assembly Quasi-Directives)
This section explains the conditional assembly control instructions (conditional assembly quasi-directives). 3.15.1 $SET, $RESET The RA78K4 uses the $SET control instruction and $RESET quasi-directive to define a value for a switch name of conditional assembly. The CA850 does not have such a control instruction. Define a switch name by using the .set quasi-directive. [RA78K4] $SET: Gives a true value (0FFH) to a switch name specified by the IF/ELSEIF control instruction. The description format is as follows. $SET (switch name [: switch name ...]) $RESET: Gives a false value (0H) to a switch name specified by the IF/ELSEIF control instruction. The description format is as follows. $RESET (switch name [: switch name ...])
$SET $RESET (SWSYM0) (SWSYM1)
[CA850] Not provided. Use the .set quasi-directive.
.set .set SWSYM0,0xff SWSYM1,0
Application Note U15653EJ1V0AN
103
CHAPTER 3 ASSEMBLY LANGUAGE
3.15.2 $IF, .ifdef The RA78K4 performs assembly if the switch name specified by the $IF control instruction is true. The CA850 performs assembly if the switch name specified by the .ifdef quasi-directive is defined. [RA78K4] $IF: Assembles until the next conditional assembly quasi-directive appears if the specified switch name is true ( 0). If it is false (= 0), does not assemble until the next conditional assembly quasi-directive appears. The description format is as follows. $IF (switch name [: switch name ...])
$IF(SWSYM0)
[CA850] .ifdef: Assembles the blocks up to the corresponding .else, .elseif, .elseifn, or .endif quasi-directive if the name specified by the operand is defined. The description format is as follows. .ifdef name
.ifdef SWSYM0
If not, does not assemble the blocks up to the
corresponding .else, .elseif, .elseifn, or .endif quasi-directive.
3.15.3 .ifndef The CA850 performs assembly if the switch name specified by the .ifndef quasi-directive is not defined. [RA78K4] Not provided [CA850] .ifndef: Assembles the blocks up to the corresponding .else, elseif, elseifn, or .endif quasi-directive if the name specified by the operand is not defined. If it is defined, does not assemble the blocks up to the corresponding .else, .elseif, .elseifn, or .endif quasi-directive. The description format is as follows. .ifndef name
.ifndef SWSYM3
104
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
3.15.4 $_IF, .if The RA78K4 performs assembly if the conditional expression of the $_IF control instruction is true. The CA850 performs assembly if the expression of the .if quasi-directive is true. [RA78K4] $_IF: Assembles until the next conditional assembly quasi-directive appears if the specified conditional expression is true ( 0). If it is false (= 0), does not assemble until the next conditional assembly quasi-directive appears. The description format is as follows. $_IF conditional expression
$_IF SWSYM2 = 0
[CA850] .if: Assembles the blocks up to the corresponding .else, .elseif, .elseifn, or .endif quasi-directive if the absolute expression specified by the operand is true ( 0). If it is false (= 0), does not assemble the blocks up to the corresponding .else, .elseif, .elseifn, or .endif quasi-directive. The description format is as follows. .if absolute expression
.if SWSYM2==0
3.15.5 .ifn The CA850 performs assembly if the expression of the .ifn quasi-directive is false. [RA78K4] Not provided. [CA850] .ifn: Assembles the blocks up to the corresponding .else, .elseif, .elseifn, or .endif quasi-directive if the absolute expression specified by the operand is false (= 0). If it is true ( 0), does not assemble the blocks up to the corresponding .else, .elseif, .elseifn, or .endif quasi-directive. The description format is as follows. .ifn absolute expression
.ifn SWSYM2==5
Application Note U15653EJ1V0AN
105
CHAPTER 3 ASSEMBLY LANGUAGE
3.15.6 $ELSEIF, $_ELSEIF, .elseif The RA78K4 uses the $ELSEIF control instruction for symbols and the $_ELSEIF control instruction for expressions and the CA850 uses the .elseif quasi-directive to assemble if a condition is true when the conditions of the previous assembly control instructions are not satisfied. [RA78K4] $ELSEIF: Judges a condition only if the conditions of all the previously described conditional assembly control instructions are not satisfied. If the specified switch name is true ( 0), assembles until the next conditional assembly quasidirective appears. If it is false (= 0), does not assemble until the next conditional assembly quasidirective appears. The description format is as follows. $ELSEIF (switch name [: switch name ...]) $_ELSEIF: Judges a condition only if the conditions of all the previously described conditional assembly control instructions are not satisfied. If the specified condition expression is true ( 0), assembles until the next conditional assembly quasi-directive appears. If it is false (= 0), does not assemble until the next conditional assembly quasi-directive appears. The description format is as follows. $_ELSEIF conditional expression
$ELSEIF(SWSYM1) $_ELSEIF SWSYM2 = 0FFH
[CA850] .elseif: Judges a condition only if the conditions of all the previously described conditional assembly quasi-directives are not satisfied. If the absolute expression specified by the operand is true ( 0), assembles the blocks up to the corresponding .else, .elseif, .elseifn, or .endif quasi-directive. If it is false (= 0), does not assemble the blocks up to the corresponding .else, .elseif, .elseifn, or .endif quasi-directive. The description format is as follows. .elseif absolute expression
.elseif SWSYM2==0xff
106
Application Note U15653EJ1V0AN
CHAPTER 3 ASSEMBLY LANGUAGE
3.15.7 .elseifn The CA850 uses the .elseifn quasi-directive to judge a condition if the conditions of all the previous conditional assembly control instructions are not satisfied, and assembles if the expression specified by the operand is false. [RA78K4] Not provided. [CA850] .elseifn: Judges a condition only if the condition of all the previously described conditional assembly quasidirectives are not satisfied. If the absolute expression specified by the operand is false (= 0), assembles the blocks up to the corresponding .else, .elseif, .elseifn, or .endif quasi-directive. If it is true ( 0), does not assemble the blocks up to the corresponding .else, .elseif, .elseifn, or .endif quasi-directive. The description format is as follows. .elseifn absolute expression
.elseifn SWSYM2==0xff
3.15.8 $ELSE, .else The RA78K4 uses the $ELSE control instruction and the CA850 uses the .else quasi-directive to specify assembling if all previous conditional assembly control instructions are false. [RA78K4] $ELSE: If the conditions of all previously described conditional assembly control instructions are not satisfied, assembles until the ENDIF control instruction appears after the ELSE control instruction. The description format is as follows. $ELSE [CA850] .else: If the conditions of all the previously described conditional assembly quasi-directives are not satisfied, assembles statements enclosed by the .else quasi-directive and .endif quasi-directive corresponding to this quasi-directive. The description format is as follows. .else
Application Note U15653EJ1V0AN
107
CHAPTER 3 ASSEMBLY LANGUAGE
3.15.9 $ENDIF, .endif The RA78K4 uses the $ENDIF control instruction and the CA850 uses the .endif quasi-directive to define the end of conditional assembly. [RA78K4] $ENDIF: Informs the assembler of the end of the source statement subject to conditional assembly. The description format is as follows. $ENDIF [CA850] .endif: Indicates the end of the range of control by a conditional assembly quasi-directive. The description format is as follows. .endif
3.16 SFR Area Change Control Instructions
This section explains the SFR area change control instructions. 3.16.1 $CHGSFR, $CHGSFRA The 78K/IV Series can change the address of the SFR area by using the LOCATION instruction. At this time, the SFR area whose address is to be changed is specified by the SFR area change control instruction. The V850 Family does not have such a function and therefore does not have a quasi-directive equivalent to the SFR area change control instruction. [RA78K4] $CHGSFR: Specifies an address of the SFR area by the absolute expression of the operand. The description format is as follows. $CHGSFR (absolute expression) $CHGSFRA: Instructs to create an object that can be linked regardless of the SFR area. The description format is as follows. $CHGSFRA [CA850] Not provided
108
Application Note U15653EJ1V0AN
CHAPTER 4 LINK DIRECTIVES
This chapter explains the points to be noted about the link directives of the linker (link editor) and the basic method of describing the link directives.
4.1 Contents of Link Directive
The contents described in the link directive file of the lk78k4 of the RA78K4 and the Id850 of the CA850 are as follows. Table 4-1. Link Directives
RA78K4 Memory directive Segment allocation directive Segment directive Mapping directive Symbol directive CA850
In the RA78K4, the directives do not have to be described in the order of addresses, whereas they do in the CA850. The RA78K4 does not have a symbol directive that generates a symbol. The CA850 requires description of a symbol directive to generate the TP, GP, and EP symbols.
Application Note U15653EJ1V0AN
109
CHAPTER 4 LINK DIRECTIVES
4.2 Description of Link Directive
The description format of the link directives of the RA78K4 and CA850 is as follows. [RA78K4] Memory directive MEMORY memory area name: (start address value, size) [/memory space name] Segment allocation directive MERGE segment name: [AT (start address)] [= memory area name specification] [/memory space name]
memory TBL memory ROM memory RAM1 memory STK memory SDR memory SDR1 memory RAM : ( 000000h , 00080h ) : ( 000080h , 0BF80h ) : ( 0FF700h , 00600h ) : ( 0FFD00H, 00020h ) : ( 0FFD20h , 000E0h ) : ( 0FFE00h , 00080h ) : ( 0FFE80h , 00180h )
merge @@INIT merge @@DATA merge @@INIS merge @@DATS merge @@BITS merge @@INIS1 merge @@DATS1 merge @@BITS1
: = RAM1 : = RAM1 : = SDR : = SDR : = SDR : = SDR1 : = SDR1 : = SDR1
memory EXMEM : (050000H, 1000H)
merge
DAT1 := EXMEM
110
Application Note U15653EJ1V0AN
CHAPTER 4 LINK DIRECTIVES
[CA850] Segment directive Segment name: !segment type ?segment attribute [V address] [L maximum memory size] [H hole size] [F filling value] [A alignment condition] {mapping directive}; Mapping directive section name = $section type ?section attribute [section name] [V address] [H hole size] [A alignment condition] [{file name [file name]...}]; Symbol directive symbol name @%symbol type [&base symbol name] [V address] [A alignment condition] [{segment name[segment name]...}];
Application Note U15653EJ1V0AN
111
CHAPTER 4 LINK DIRECTIVES

SCONST .sconst }; : !LOAD ?R { = $PROGBITS ?A .sconst;
TEXT
: !LOAD ?RX { ?AX; ?AX;
.pro_epi_runtime = $PROGBITS .text }; = $PROGBITS
DATA .data .sdata .sbss .bss };
: !LOAD ?RW V0x100000 { = $PROGBITS = $PROGBITS = $NOBITS = $NOBITS ?AW.data; ?AWG.sdata; ?AWG.sbss; ?AW.bss;
CONST .const };
: !LOAD ?R { = $PROGBITS ?A .const;
SEDATA .sedata .sebss };
: !LOAD ?RW V0xff6000 { = $PROGBITS = $NOBITS ?AW .sedata; ?AW .sebss;
SIDATA
: !LOAD ?RW V0xffe000 { = $PROGBITS = $NOBITS = $PROGBITS = $NOBITS = $PROGBITS = $NOBITS = $PROGBITS = $NOBITS ?AW .tidata.byte; ?AW .tibss.byte; ?AW .tidata.word; ?AW .tibss.word; ?AW .tidata; ?AW .tibss; ?AW .sidata; ?AW .sibss;
.tidata.byte .tibss.byte .tidata.word .tibss.word .tidata .tibss .sidata .sibss };
__tp_TEXT @ %TP_SYMBOL; __gp_DATA @ %GP_SYMBOL &__tp_TEXT{DATA}; __ep_DATA @ %EP_SYMBOL;
112
Application Note U15653EJ1V0AN
CHAPTER 5 TRANSLATION LIMIT
This chapter compares the translation limit values of the CC78K4 and CA850 during compilation. The results of the comparison are as follows. Table 5-1. Translation Limit Value
No. 1 2 3 Item Nesting of compound, repeat control, and selection control statements Nesting of conditional compiling Number of pointers, arrays, and function declarators (or any combination of these) qualifying one arithmetic type, structure type, union type, or incomplete type in one declaration, Number of levels of nesting declarators enclosed in parentheses in a complete declarator Number of levels of nesting expressions enclosed in parentheses in a complete expression Number of valid first characters in a macro name Number of valid first characters in an external symbol name Number of valid first characters in an internal symbol name Number of symbols in one source module file Number of symbols having block scope in one block Number of macros in one source module file Parameter of one function definition or one function call Parameter of one macro definition or one macro call Number of characters on one logic source line Number of characters in a character string literal after linking Nesting of include files Number of case labels of a switch statement Number of members of one structure or union Number of enumeration constants of one enumeration Nesting of structures or unions in one structure or union CC78K4 45 255 12 CA850 127 255 16
4
591
255
5
32
255
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
31 30 30 1024 255 10000 39 31 509 509 8 257 127 255 15
1023 1022 1023 4095
2047Note 255 127 32766 32766 50 1025 1023 1023 63
Note This can be changed by a C compiler option (-Xm) (up to 32767).
Application Note U15653EJ1V0AN
113
APPENDIX INDEX
[A]
Absolute address access ................................... 19, 27 Alignment conditions .......................................... 48, 78 ar850........................................................................ 16 Archiver .................................................................... 16 Area reservation quasi-directive............................... 66 as850 ....................................................................... 16 Assemble end quasi-directive ............................ 66, 98 Assemble list control instruction ....................... 67, 102 Assemble target model specification control instruction ............................................... 66, 99 Assembler control quasi-directive ...................... 66, 99 Assembler instruction......................................... 19, 20 Assembler ................................................................ 16 Automatic selection quasi-directive .................... 66, 90 #asm ........................................................................ 20 .align .................................................................. 65, 78 __asm ................................................................ 20, 21
char...........................................................................47 Character string function...........................................63 Character string ........................................................87 Character string/memory function.............................63 Compiler-defined macros..........................................18 Conditional assembly quasi-directive................67, 103 Conditional assembly control instruction...........67, 103 Control instructions ...................................................65 Control of interrupt disabling...............................19, 25 Copying ROMization default value data....................64 CPU control instruction .......................................19, 26 Cross-reference list output specification control instruction .........................................................66, 100 Cross-reference tool .................................................16 CSEG ...........................................................61, 65, 68 cxref..........................................................................16 $CHGSFR.........................................................67, 108 $CHGSFRA ......................................................67, 108 $COND .............................................................67, 102 .comm.................................................................66, 89 .const ............................................................62, 65, 68 @@CALF .................................................................61 @@CALT .................................................................61 @@CNST.................................................................61 @@CODE ................................................................61
[B]
Binary constant .................................................. 38, 45 Bit access........................................................... 38, 43 Bit field ..................................................................... 42 Bit type variable.................................................. 38, 42 bit ....................................................................... 38, 42 boolean .............................................................. 38, 42 BR ...................................................................... 66, 90 BRK.......................................................................... 26 BSEG ........................................................... 61, 65, 75 .binclude........................................................... 66, 101 .bss .............................................................. 62, 65, 70 .byte ................................................................... 66, 81 @@BASE ................................................................ 61 @@BITS.................................................................. 61 @@BITS1................................................................ 61 __boolean1 ........................................................ 38, 42
[D]
Data insertion function ........................................19, 35 DB.......................................................................66, 81 DBIT ...................................................................66, 86 Debug information output control instruction ....66, 100 Device file .................................................................15 Device type.........................................................19, 37 DG ......................................................................66, 83 DI ........................................................................24, 25 dis850 .......................................................................16 Disassembler ............................................................16 Division function..................................................19, 35 divuw ........................................................................35 double.......................................................................47 DS.......................................................................66, 85 DSEG ...........................................................61, 65, 70 Dump directive..........................................................16 dump850...................................................................16 DW......................................................................66, 82
[C]
C compiler ................................................................ 16 ca850 ....................................................................... 16 CALL .................................................................. 66, 90 callf..................................................................... 38, 44 callt..................................................................... 38, 39 cc78k4...................................................................... 16
114
Application Note U15653EJ1V0AN
APPENDIX INDEX
$DEBUG .......................................................... 66, 100 $DEBUGA........................................................ 66, 100 .data............................................................. 62, 65, 70 @@DATA ................................................................ 61 @@DATS ................................................................ 61 @@DATS1 .............................................................. 61 __DATE__ ............................................................... 18
General-purpose registers........................................54 Global pointer ...........................................................54 $GEN................................................................67, 102 .globl...................................................................66, 87
[H]
HALT ........................................................................26 Hardware initialization function.................................55 Header file ................................................................64 Heap area.................................................................52 Hex converter ...........................................................16 hx850........................................................................16 .hword.................................................................66, 82
[E]
EI ....................................................................... 24, 25 Element pointer........................................................ 54 END ................................................................... 66, 98 ENDM ................................................................ 66, 98 EQU ................................................................... 65, 79 exit function.............................................................. 59 EXITM................................................................ 66, 96 EXTBIT .............................................................. 66, 89 Extended descriptions.............................................. 38 EXTRN............................................................... 66, 88 #endasm .................................................................. 20 $_ELSEIF ........................................................ 67, 106 $EJECT ........................................................... 67, 102 $ELSE.............................................................. 67, 107 $ELSEIF .......................................................... 67, 106 $ENDIF ............................................................ 67, 108 .else ................................................................. 67, 107 .elseif ............................................................... 67, 106 .elseifn ............................................................. 67, 107 .endif ................................................................ 67, 108 .endm................................................................. 66, 98 .exitm ................................................................. 66, 96 .exitma ............................................................... 66, 96 .extern................................................................ 66, 88
[I]
I/O function ...............................................................63 Include control instruction.................................66, 101 Inline expansion .................................................19, 30 int..............................................................................47 Integer operation ......................................................64 Interrupt disabled function ..................................19, 24 Interrupt function ..........................................19, 22, 24 Interrupt handler supporting real-time OS ..........19, 36 Interrupt level......................................................38, 46 ioreg .........................................................................20 IRP .....................................................................66, 95 $_IF ..................................................................67, 105 $IF ....................................................................67, 104 $INCLUDE........................................................66, 101 .if.......................................................................67, 105 .ifdef..................................................................67, 104 .ifn.....................................................................67, 105 .ifndef................................................................67, 104 .include .............................................................66, 101 .irepeat ...............................................................66, 95 @@INIS ...................................................................61 @@INIS1 .................................................................61 @@INIT ...................................................................61 __interrupt ..........................................................22, 23 __interrupt_blk..........................................................22
[F]
File input control quasi-directive ...................... 66, 101 float .......................................................................... 47 Floating-point operation ........................................... 64 Floating-point value.................................................. 87 $FORMFEED................................................... 67, 102 .file ..................................................................... 65, 80 .float ................................................................... 66, 87 .frame................................................................. 65, 80 __FILE__ ................................................................. 18
[K]
__K4__ .....................................................................18
[L]
lb78k4.......................................................................16 ld850.........................................................................16 lcnv78k4 ...................................................................16 Librarian ...................................................................16
[G]
General-purpose register selection quasi-directive.................................................... 66, 91
Application Note U15653EJ1V0AN
115
APPENDIX INDEX
Library ...................................................................... 63 Link directive .......................................................... 109 Link editor................................................... 52, 58, 109 Linkage quasi-directive ...................................... 66, 87 Linker ............................................................... 16, 109 List converter............................................................ 16 lk78k4....................................................................... 16 LOCAL ............................................................... 66, 93 Location counter quasi-directive............................... 65 Location instruction .................................................. 53 long .......................................................................... 47 $LENGTH......................................................... 67, 102 $LIST ............................................................... 67, 102 .lcomm................................................................ 66, 85 .local................................................................... 66, 93 __LINE__ ................................................................. 18
$NOSYMLIST ...................................................66, 100 $NOXREF.........................................................66, 100
[O]
Object converter .......................................................16 Object module name.................................................80 Object module name declaration quasi-directive.....................................................65, 80 oc78k4 ......................................................................16 ORG ...................................................................65, 77 .option.................................................................66, 99 .org .....................................................................65, 77 __OPC......................................................................35
[P]
Pascal function ...................................................38, 46 pc850........................................................................16 Performance checker................................................16 Peripheral function register.......................................16 Product name ...........................................................15 Program control function...........................................63 Program linkage quasi-directive .........................66, 87 PUBLIC...............................................................66, 87 #pragma access .................................................19, 27 #pragma asm................................................19, 20, 21 #pragma block_interrupt .....................................19, 24 #pragma brk .......................................................19, 26 #pragma cpu.......................................................19, 37 #pragma di..........................................................19, 25 #pragma directives ...................................................19 #pragma div........................................................19, 35 #pragma ei..........................................................19, 25 #pragma endasm................................................19, 21 #pragma halt.......................................................19, 26 #pragma inline ....................................................19, 30 #pragma interrupt .........................................19, 22, 23 #pragma ioreg ....................................................19, 20 #pragma mul.......................................................19, 34 #pragma name....................................................19, 30 #pragma nop ......................................................19, 26 #pragma opc.......................................................19, 35 #pragma pack .....................................................19, 38 #pragma pc.........................................................19, 37 #pragma peekb.........................................................27 #pragma peekw ........................................................27 #pragma pokeb.........................................................27 #pragma pokew ........................................................27 #pragma rot ........................................................19, 31
[M]
Macro quasi-directive ......................................... 66, 92 MACRO.............................................................. 66, 92 main function............................................................ 59 Mask register............................................................ 54 Mathematical function .............................................. 63 Memory initialization, area reservation quasi-directive .................................................... 66, 81 Memory layout visualization tool .............................. 16 MEMORY ............................................................... 110 MERGE .................................................................. 110 Module ................................................... 19, 29, 30, 50 moduw...................................................................... 35 Multiplication function......................................... 19, 34 mulu ......................................................................... 34 muluw....................................................................... 34 mulw......................................................................... 34 .macro ................................................................ 66, 92 __multi_interrupt ...................................................... 23
[N]
NAME................................................................. 65, 81 noauto ...................................................................... 38 NOP ......................................................................... 26 norec ........................................................................ 38 $NOCOND ....................................................... 67, 102 $NODEBUG ..................................................... 66, 100 $NODEBUGA................................................... 66, 100 $NOFORMFEED.............................................. 67, 102 $NOGEN .......................................................... 67, 102 $NOLIST .......................................................... 67, 102
116
Application Note U15653EJ1V0AN
APPENDIX INDEX
#pragma rtos_interrupt....................................... 19, 36 #pragma rtos_task ............................................. 19, 37 #pragma section ................................................ 19, 29 #pragma sfr........................................................ 19, 20 #pragma stop..................................................... 19, 26 #pragma text...................................................... 19, 29 #pragma vect ..................................................... 19, 22 $PROCESSOR .................................................. 66, 99 .previous ............................................................ 65, 76 .pro_epi_runtime ...................................................... 62
Section file generator................................................16 Segment ...................................................................60 Segment output by compiler.....................................61 Segment quasi-directive .....................................65, 68 SET ....................................................................65, 79 sf850.........................................................................16 SFR area change control instruction ................67, 108 sfr .............................................................................20 short .........................................................................47 Skip quasi-directive ............................................66, 92 sld.......................................................................72, 73 Special function ........................................................63 Special function register name ...........................19, 20 Special registers .......................................................55 sreg ..........................................................................38 sst.......................................................................72, 73 st78k4.......................................................................16 Stack area ................................................................53 Stack pointer ............................................................54 Startup module .........................................................50 Startup routine..........................................................50 STOP........................................................................26 Structure packing ...............................................19, 38 Structured assembler ...............................................16 Symbol control quasi-directive............................65, 78 Symbol definition quasi-directive ........................65, 78 $SET ................................................................67, 103 $SUBTITLE ......................................................67, 102 $SYMLIST ........................................................66, 100 .sbss .............................................................62, 65, 70 .sconst ..........................................................62, 65, 68 .sdata............................................................62, 65, 70 .sebss ...........................................................62, 65, 70 .section ...............................................................65, 76 .sedata..........................................................62, 65, 70 .set......................................................................65, 79 .shword.....................................................................85 .sibss ............................................................62, 65, 70 .sidata...........................................................62, 65, 70 .size ....................................................................65, 80 .space.................................................................66, 84 .str ............................................................................87 __set_il ...............................................................38, 46 __sreg1 ..............................................................38, 40 __STDC__................................................................18
[Q]
Quasi-directives ....................................................... 65
[R]
ra78k4...................................................................... 16 rammap.................................................................... 16 Real-time OS function........................................ 19, 37 Register bank........................................................... 54 Register variable ................................................ 38, 39 register..................................................................... 38 Repeat assemble quasi-directive ....................... 66, 92 REPT ................................................................. 66, 94 Reserving memory area........................................... 81 Reset vector............................................................. 53 rolb........................................................................... 31 rolw .......................................................................... 31 ROMization processor ............................................. 16 ROMization .............................................................. 56 romp850................................................................... 16 rompsec ................................................................... 62 rorb .......................................................................... 31 rorw.......................................................................... 31 Rotate function................................................... 19, 31 RSS ................................................................... 66, 91 Runtime library................................................... 62, 64 $RESET........................................................... 67, 103 .repeat................................................................ 66, 94 @@R_INIT .............................................................. 61 @@R_INS ............................................................... 61 @@R_INS1 ............................................................. 61 __rtos_interrupt........................................................ 36 _rcopy ...................................................................... 58
[S]
saddr.................................................................. 38, 40 Section ........................................................ 19, 29, 60 Section definition quasi-directive........................ 65, 68
[T]
Text pointer ..............................................................54
Application Note U15653EJ1V0AN
117
APPENDIX INDEX
Translation limit ...................................................... 113 $TAB ................................................................ 67, 102 $TITLE ............................................................. 67, 102 .text .............................................................. 62, 65, 68 .tibss............................................................. 62, 65, 70 .tibss.byte ........................................................... 65, 70 .tibss.word .......................................................... 65, 70 .tidata ........................................................... 62, 65, 70 .tidata.byte.......................................................... 65, 70 .tidata.word......................................................... 65, 70 __TIME__................................................................. 18
[U]
Utility function........................................................... 63
[V]
.vdbstrtab ................................................................. 65 .vdebug .................................................................... 65 .vline......................................................................... 65 @@VECT ................................................................ 61 __v850 ..................................................................... 18 __v850__ ................................................................. 18
[W]
$WIDTH ........................................................... 67, 102 .word .................................................................. 66, 84
[X]
$XREF.............................................................. 66, 100
118
Application Note U15653EJ1V0AN
Facsimile Message
From:
Name Company
Although NEC has taken all possible steps to ensure that the documentation supplied to our customers is complete, bug free and up-to-date, we readily accept that errors may occur. Despite all the care and precautions we've taken, you may encounter problems in the documentation. Please complete this form whenever you'd like to report errors or suggest improvements to us.
Tel.
FAX
Address
Thank you for your kind support.
North America Hong Kong, Philippines, Oceania NEC Electronics Inc. NEC Electronics Hong Kong Ltd. Corporate Communications Dept. Fax: +852-2886-9022/9044 Fax: +1-800-729-9288 +1-408-588-6130 Korea Europe NEC Electronics Hong Kong Ltd. NEC Electronics (Europe) GmbH Seoul Branch Technical Documentation Dept. Fax: +82-2-528-4411 Fax: +49-211-6503-274 South America NEC do Brasil S.A. Fax: +55-11-6462-6829 Taiwan NEC Electronics Taiwan Ltd. Fax: +886-2-2719-5951 Asian Nations except Philippines NEC Electronics Singapore Pte. Ltd. Fax: +65-250-3583
Japan NEC Semiconductor Technical Hotline Fax: +81- 44-435-9608
I would like to report the following error/make the following suggestion: Document title: Document number: Page number:
If possible, please fax the referenced page or drawing. Document Rating Clarity Technical Accuracy Organization
CS 01.2
Excellent
Good
Acceptable
Poor


▲Up To Search▲   

 
Price & Availability of USAA13CA703000-XX

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X